Skip to main content
stinky.blog

Shell expansion

Globbing #

Expand filenames with wildcards. * represents any pattern. ? represents any single character.

list everything:

ls *

list things that start with "a" and are at least 2 characters long:

ls a?*

list things that begin with lowercase a - e:

ls [a-e]*

Braces #

Perform this action on 1 through 9:

touch file{1..9} 

Perform this action on all these terms:

useradd {lisa,linda,anna}

Substitution #

Search for the output of the command:

ls -l $(which ls)

Use variable contents in command:

echo $PATH