Linux metacharacters

Here is the meaning of some metacharacters:
* = Matches any sequence of zero or more characters, except for “.” (a dot) at the beginning of a filename.
? = Matches any single character.
[abC1] = Matches a single character in the enumerated set. In this example the set contains: ‘a’, ‘b’, ‘C’, and ’1′.
[a-z] = Matches any lower-case letter.
[A-F] = Matches any upper-case letter from A to F.
[0-9] = Matches any single digit.
[a-zA-Z0-9] = Matches any letter (lower or upper case) or any digit.
The character \ (backslash) is also special. It makes the subsequent special character aquire literal meaning (read on).

Examples. This command will list any filename in the current directory, with the exception of filenames starting with “.” (dot):

ls *

An equivalent to this command is to type just ls or dir (without the “*”). Files with names starting with “.” are not shown because “.” as the first character of a filename is not matched by “*”. Think of files with names starting with “.” as an equivalent of DOS hidden files. Use ls -a (list with the option “all”) or ls .* to see these “dot” files. The “dot-files” are common in the user home directories and they typically contain user-level configurations.
This command will list any file (in the current directory) that contains a dot (except files starting with a dot):

ls *.*

This entry was posted in Linux, Other Tech. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>