Wild Card Characters In Unix/Linux

*: It matches zero (or) more characters in the given file  


$  ls a* ---->Displaying files star with ‘a”.

$  ls  i*---->Start with ‘I” end with ‘g’

$ ls   *g---->list out  end with ‘g’ only

$ rm I *---->removes start with i

$cp  a* Documents/copies start with a

$ cp - rf I * g Documents /

$  cp - rvf * / backup copies current directory all files

? : It matches any single character in the given file  


$ ls ?---->Display single character files.

$ ls ??---->Two character files

$ ls a ??? ---->list four character files but first one is ‘a’.

$ rm ??  ---->Removes two character files.

$ cp ??? Documents/ copies three character files.

[     ]: It matches any single characters in the given list.

Inclined to build a profession as Linux Developer? Then here is the blog post on, explore Linux Training

Ex: $ ls [aeiou] ---->Displays given matching character files.

$ ls [aeiou] * ---->Displays start with a,e,I,o,u files.

$ rm [aeiou] *---->Removing start with a,e,I,o,u

$ cp [aeiou] * Unix/copying start with a,e,I,o,u    

[  -   ] : It matches any single characters in the given range.


$ ls [a-f]  *---->Displays start with a,b,c,d,e,f

$ ls [a-f, o-v] * ---->Display start with a-e & o-v

$ rm  [a-f] *---->Removes a-f

$ cp  [a-f, 1-9]  *  Unix/copying files a-f & 1-9


Linux Tutorials


For an in-depth understanding of Linux click on