Wildcard in Linux
Wildcards are a set of building blocks that allow you to create a pattern defining a set of files or directories.
Here is the basic set of wildcards:
- * - represents zero or more characters
- ? - represents a single character
- [] - represents a range of characters
Wildcards may be used with any command.
- * -
It represents zero or more characters. If you want to list all the files and directories then this wildcard is very beneficial.In simple words, whenever you use * means it will include all the character.
ls *
E.g. if you want to list all the directory which starts with D. Then you just have to write.
ls D*
it will list all the directories and files of those directories which starts with D.

suppose you want to search all files with extension png.
ls path *.png
Here path is from where you want to list all png.

- ? -
it represents one character. This wildcard is used as a filter like if you want to search a directory whose second letter is o or whose extension is of 3 words.. etc. It is mainly used with * wildcard.

it means list all the file whose first letter is unknown but second character is o and I do not care about remaining characters in the file name.

it means I do not care about the file name. I care about extension only whose length consists of 3 characters.
It represents the range of characters. so, it is also called range operator.
- [] -
It represents the range of characters. so, it is also called range operator.
suppose you want to see all files or folders whose name starts with M, V, and f.
![[] in linux](https://imgur.com/7rcI2fq.png)
or you want to list all files which are in the range between A-F.

I guess you got the basic understanding about wildcard.
Comments
Post a Comment