A Peek at Metacharacters


Metacharacters are special characters that have particular meaning to your shell that dollar sign or hash mark prompt where you do your work. The two I want to look at are the asterisk and the question mark. The following is what they mean to the shell:

*

Match any number of characters.

?

Match a single character.


Extending our talk of listing files, you could list all files containing "ackle" by using this command:

 $ ls *ackle* hackle hackles tackles 

Similarly, you could find all the words that start with an "h" like this:

 $ ls h* hackle hackles 

Now, if you want to see all the seven-letter words in your directory, use this command:

 $ ls ??????? hackles tackles 

Each question mark represents a single letter position.



Moving to Linux(c) Kiss the Blue Screen of Death Goodbye!
Moving to Linux: Kiss the Blue Screen of Death Goodbye!
ISBN: 0321159985
EAN: 2147483647
Year: 2003
Pages: 247

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net