From 8f06bf7df0726b9471d18224fd62c82fc476f8b5 Mon Sep 17 00:00:00 2001 From: jbranchaud Date: Tue, 7 Jun 2016 20:19:36 -0500 Subject: [PATCH] Add Globbing For Filenames In Zsh as a unix til --- README.md | 3 ++- unix/globbing-for-filenames-in-zsh.md | 28 +++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 unix/globbing-for-filenames-in-zsh.md diff --git a/README.md b/README.md index 2736d30..a4b7b5d 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ variety of languages and technologies. These are things that don't really warrant a full blog post. These are mostly things I learn by pairing with smart people at [Hashrocket](http://hashrocket.com/). -_428 TILs and counting..._ +_429 TILs and counting..._ --- @@ -379,6 +379,7 @@ _428 TILs and counting..._ - [Find Newer Files](unix/find-newer-files.md) - [Get The Unix Timestamp](unix/get-the-unix-timestamp.md) - [Global Substitution On The Previous Command](unix/global-substitution-on-the-previous-command.md) +- [Globbing For Filenames In Zsh](unix/globbing-for-filenames-in-zsh.md) - [Grep For Files Without A Match](unix/grep-for-files-without-a-match.md) - [Grep For Multiple Patterns](unix/grep-for-multiple-patterns.md) - [Hexdump A Compiled File](unix/hexdump-a-compiled-file.md) diff --git a/unix/globbing-for-filenames-in-zsh.md b/unix/globbing-for-filenames-in-zsh.md new file mode 100644 index 0000000..a055adb --- /dev/null +++ b/unix/globbing-for-filenames-in-zsh.md @@ -0,0 +1,28 @@ +# Globbing For Filenames In Zsh + +Zsh has extensive support for _globbing_ for filenames. _Globbing_ is a +short-hand, of sorts, for generating filenames that meet certain criteria. +The generated filenames can be used with any command you might otherwise +provide a filename to in a unix setting. + +For example, consider a directory full of files including many that are +named with numbers. You'd like to list all files that have numeric names. + +Doing `ls` by itself gives the following result: + +```bash +$ ls +10 11 2 3 4 801 92 code.rb hello.txt +``` + +With the use of a numeric pattern, Zsh's _globbing_ helps `ls` limit the set +of listed files to just those with numeric names: + +```bash +$ ls *[0-9] +10 11 2 3 4 801 92 +``` + +[source](http://zsh.sourceforge.net/Intro/intro_2.html) + +h/t Josh Davey