Stay at Home!! Be Safe!! Take Care!!

Thanks all my viewers for your support, I am an Oracle Ace now. For Any queries, please mail us at support@funoracleapps.com

Globbing/Wildcards in Linux

No comments

Globbing/Wildcards in Linux


Globbing in linux is referred to the use of wildcards. Wildcards, in the Linux file system, allow you to refer to files in a flexible way. 

Types of  Wildcards  in Linux

1) * - Star is for everything. Unlimited number of characters. 
example:
ls *
It will give all file names in the current directory, no matter how long they are. 

ls a*

All files starting with a

2) ? - Question mark is for one single character. 
example:
ls ?

It will give all filesname with single character

3) [] - Square brackets, you can specify a range. 

example:
ls [a-c]

It will search with filenames as a, b, or c. It's a range. 

We can combine them with other wildcards as well.

example:
ls [a-c]*

It will show all files names starting with a or b or c.

example:

ls ?[z-s]*

It will show you all files where the second character is a z or an s. 

example:

ls *?

star already covers all characters and if we put anything behind a star, that makes no sense, especially if you make that star question mark. 


example:

ls *?[a-c]
It will mean all files that have a letter(a/b/c) on the last position. In this case, the file name must be at least two characters long.

No comments :

Post a Comment