Wednesday, October 21, 2009

Bash Globbing

Globbing refers to the expansion of shell metacharacters to complete file names. For example, when you run ls *, the shell expands the wildcard * into a list of files and passes them as arguments to ls.
sharfah@starship:~> ls *
file1 File2
Dot Globbing
By default, Bash does not glob dot-files. This means that ls * will not pick up any files beginning with the dot (.) character. However, it is easy to change this by doing the following:
sharfah@starship:~> shopt -s dotglob
sharfah@starship:~> ls *
.dotFile1 file1 File2
Case-Insensitive Globbing
There is also an option to turn on case-insensitive globbing:
sharfah@starship:~> shopt -s nocaseglob
sharfah@starship:~> ls f*
file1 File2
To view a list of all your shell options, type shopt.

No comments:

Post a Comment