Before we move to file globbing, let’s understand what are wildcard patterns, these are the patterns containing strings like ‘?’, ‘*’
File globbing is the operation that recognises these patterns and does the job of file path expansion.
See the below example for clear understanding,
If you observe the image above, I created several directories whose starting characters are HELLO and hello, and then tried to delete these directories.
When I used rm -rf hello*, it deleted the directories hello1, hello2, hello3, the ‘*’ symbol used after ‘hello’ recognises the first characters as ‘hello’ and then zero or more occurrences of any other characters.
Examples using other wildcard characters :
1) arterisk (*)
* is used to match any number of characters(zero or more), to understand more you can refer the example taken above.
In above image, you can observe that ‘?’ can match exactly one character and is used at the end of the line.
So using ‘hello?’ will match all files or directories whose starting characters are ‘hello’ and it will recognise one more character.
 can be used to match exact characters or you can also specify a range, like in above example, using ‘hello[1-5]’ will display all files and directories staring with ‘hello’, then the next character can be a numbers from 1 to 5.
4) exclamation mark (!)
! is used to exclude characters from list that is specified within the square brackets.
ls hello[!3] It will display the directories starting with hello, ending with any character but not 3
- proc file system in Linux
- file command in Linux with examples
- Linux File Hierarchy Structure
- Linux Virtualization : Linux Containers (lxc)
- who command in Linux
- Some useful Linux Hacks
- Fun Commands in Linux
- 'dd' command in Linux
- while command in Linux with example
- Different Shells in Linux
- Permissions in Linux
- Linux | Nmon
- od command in Linux with example
- Linux Commands
- du Command in LINUX
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.