Wildcards in Linux

Wildcards

Wildcards are a set of characters that allow us to create a pattern defining a set of files or directories.

There are some basic set of wildcards includes:-
* represents zero or more characters.
? represents a single character.
[ ] represents a range of characters.

* Wildcard character- we can use this wildcard to replace any number of characters in a file.
E.g. ls n*
This results in a list of files/Directories that begins with n alphabet.
? Wildcard character- using this wildcard we can represent a single character. If we write
E.g. ls x?????? 
This will result in a list of files/Directories that begins with letter x and have exactly six characters after x.  Such as xyz.txt

[ ] Wildcard character- using this wildcard we can represent a range of characters. If we write
E.g. ls [a-c]*
Now this will result in a list of files/Directories that begins with a to c alphabets. Such as abc.txt, alltextfiles.txt, cat, computer.txt etc.


UNIT-301
Network Operating System