linux wildcard examples
DESCRIPTION
A few descriptions on the use of powerful Linux wildcardsTRANSCRIPT
< Wildcard examples >
Let's have a few examples. Probably the * character is already familiar to you, because it's widely used in many other places, too, not just in Linux. For example, the following removes every file from the current directory:$ rm *
The following command moves all the HTML files, that have the word "linux" in their names, from the working directory into a directory named dir1:$ mv *linux*.html dir1
The following displays all files that begin with d and end with .txt:$ less d*.txt
The following command removes all files whose names begin with junk., followed by exactly three characters:$ rm junk.???
With this command you list all files or directories whose names begin with hda, followed by exactly one numeral:$ ls hda[0-9]
This lists all files or directories beginning with hda, followed by exactly two numerals:$ ls hda[0-9][0-9]
The following lists all files or directories whose name starts with either hd or sd, followed by any single character between a and c:$ ls {hd,sd}[a-c]
This command copies all files, that begin with an uppercase letter, to directory dir2:$ cp [A-Z]* dir2
This deletes all files that don't end with c, e, h or g:$ rm *[!cehg]