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
- Linux File Hierarchy Structure
- Linux Virtualization : Linux Containers (lxc)
- Fun Commands in Linux
- SED command in Linux | Set 2
- Permissions in Linux
- Some useful Linux Hacks
- who command in Linux
- 'dd' command in Linux
- Linux | Nmon
- Different Shells in Linux
- fmt command in Linux with examples
- fc Command in Linux with Examples
- bc command in Linux with examples
- What’s difference between Linux and Android ?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. 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.