Open main menu

CDOT Wiki β

Changes

Ambiguous Filename Expansion
Assume the following regular files exist in your current directory
<span style="font-family:courier;>'''ls'''<br>a.txt b.txt c.txt 1.txt 2.txt 3.txt abc.txt work.txt webpage.html picture.png</span>
If you wanted to list just text files (i.e. files with the extension ".txt"), one way is to issue a command and specify each file pathname as a separate argument:
<span style="font-family:courier;>'''ls a.txt b.txt c.txt 1.txt 2.txt 3.txt abc.txt work.txt'''<br>a.txt b.txt c.txt 1.txt 2.txt 3.txt abc.txt work.txt</span>
But there is no need to type all of those file pathnames as separate arguments. You can use a special character to indicate to the Bash shell to match all files that end with the extension ".txt":
<span style="font-family:courier;>'''ls *.txt'''<br>a.txt b.txt c.txt 1.txt 2.txt 3.txt abc.txt work.txt</span>
As you can see, the most recent Linux command you issued requires the least amount of keystrokes and therefore, it most efficient.
13,420
edits