CS155 Wildcards
Vocabulary | |
---|---|
Punctuation | * , ? , [] , {} |
Grammar |
*
, ?
, []
, {}
*
– match zero or more characters
?
– match any one character
[]
– match any characters in the brackets
{}
– match any word in the brackets
.txt
% cd ~/pub % ls area-codes dwarfs.txt greek hw2Files index.php planets domains.txt Examples hw1Files hw3.tgz numbers % ls *.txt domains.txt dwarfs.txt
d
% cd ~/pub % ls d* domains.txt dwarfs.txt
n
in its name:
% cd ~/pub % ls *n* domains.txt index.php numbers planets
hw
,followed by a digit, ending with an s
% cd ~/pub % ls -d hw[0-9]*s hw1Files hw2Files
% cd ~/pub % ls -d *.{php,txt} domains.txt dwarfs.txt index.php
Move all .txt
files into the directory files
% mv *.txt files
Remove all files beginning with HW
, followed by a digit,
and ending with .file
% rm HW[0-9].file
List all files ending with .txt
or .jpg
% ls -l *.{txt,jpg} | more
~
in the examples
refers to ~cs155
, cs155’s home directory.
~cs155
instead of ~
.
~
username, doesn’t have to be changed.