Loading...
Shell Script

Wild Cards

Wildcards are the shell features. It make the command line more powerful than GUI file managers. If we want to select a big group of files in a graphical file manager, we have to use mouse. It seems simple but not every time. For suppose, there is a directory with all kinds of files and sub directories and we want to move particular named LOG files, which have the word “Linux” somewhere in the middle of the names from that directory to another. This is not so simple with mouse.

In the Linux CLI this task is simple by using shell wildcards. Wildcards are special characters which allows to select filenames that match certain patterns of characters. This helps to select even a big group of files just by typing few characters. It is the easier way than selecting the files with mouse.

List of commonly used wildcards are given below

Wildcard     Description                                                               Example
*                Zero or more matches                                                ls *.sh, ls log*.log
?            Exactly only one character                                       ls file?.txt
[]           Enclose a set of characters                                         ls file[a,b,c].txt
–              Range of characters                                                     ls file[5-2].txt
~            Denotes user home path                                            cd ~/Desktop
{}            Exactly one entire word in the options given         ls {file*.txt,log *.log}

Leave a Reply

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