mirror of
https://github.com/jbranchaud/til
synced 2026-01-15 21:18:02 +00:00
Add Globbing For Filenames In Zsh as a unix til
This commit is contained in:
28
unix/globbing-for-filenames-in-zsh.md
Normal file
28
unix/globbing-for-filenames-in-zsh.md
Normal file
@@ -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
|
||||
Reference in New Issue
Block a user