Using the asterisk and a question mark in the filter is called file globbing. File globbing is the
processing of pattern matching using wildcards. The wildcards are officially called
metacharacter wildcards. You can use more metacharacter wildcards for file globbing than
just the asterisk and question mark. You can also use brackets
Examples of globbing usage
Match all the files starting from my (my_file, myddk, mys.s.s, etc)
1 |
ls -l my* |
Match all the files starting from my_s and finishing t. Between could be any symbols (my_sDft, my_sdkdkt, etc)
1 |
ls -l my_s*t |
Match all the files starting from my_scr and finishing pt. Between can be any number of character that are a or i (my_scraaiiiaiapt, my_scraaapt, my_scriiiaiaipt, etc)
1 |
ls -l my_scr[ai]pt |
Match all the files starting from f and finishing ll. Between can be any symbols from a to i or cannot be (fll, fall, fabcdill, etc)
1 |
ls -l f[a-i]ll |
Match all the files starting from f and finish ll. the symbol a shouldn’t be between. All the rest could be. (fll, fbbll, fddddsll, etc)
1 |
ls -l f[!a]ll |