Wildcarding allows you to specify groups of files. You can
use wildcards as an argument to ls
, cp
,
mv
, and rm
, as well as to UNIX
filters.
Wildcard | What it Represents |
---|---|
? | any character |
* | any glob of zero or more characters |
[crmf] | any of c, m, r or f. You can put any list of caracters in the brackets to create a wildcard. |
[a-z] | any charcter falling asciicograpically from a to z. You can put any range of characters you wish in here and you can have more than one range. |
Here are some useful examples and what they do.
ls *.html
List all HTML files in your cwdls */index.html
List any file nameadindex.html
in any immediate subdirectory of your cwdgrep -l cos *.c
List all.c
files that contain the string "cos" in your current working directory.cat *f* |grep -i washington
Put all lines from files containing the letter f in your cwd that contain the word "washington" case-insensitive tostdout
.ls [a-f][q-z]*.html
This lists all files starting with a lower-case letter a-f then a lower case letter q-z followed by any other characters which have a.html
extension.- (desperation search)
grep -il */* regalis
Print the names of all files one folder down that contain the text stringregalis
, case insensitive. Where'd I put those notes???