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
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- File Management in Linux
- Advance File Permissions in Linux
- Kali Linux - File Management
- proc file system in Linux
- file command in Linux with examples
- Linux File Hierarchy Structure
- How to copy a file's content from Linux terminal?
- SetUID, SetGID, and Sticky Bits in Linux File Permissions
- Difference Between Arch Linux and Kali Linux
- Linux Virtualization : Linux Containers (lxc)
- Why Linux is Better?
- 'dd' command in Linux
- 10 Best Linux VPS Hosting
- Wikit in Linux
- Linux vs Unix
- Filters in Linux
- Permissions in Linux
- du Command in LINUX
- Fun Commands in Linux
- Different Shells 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 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.