Meta characters (or) wild card characters

Meta characters (or) wild card characters in Unix/Linux:

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

 

EX:       $  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

(b)   ?     :    It matches any single character in the given file

 

Ex:        $ 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.

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

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

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

 

 

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

EX:       $ 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

For indepth understanding of Linux click on