Changes

Jump to: navigation, search
Ambiguous Filename Expansion
===Ambiguous Filename Expansion===
xSometimes when issuing Linux commands, it could be more efficient to use a trick to process several files that share the same characteristic (for example, the same extension, or the same file naming structure). For example: Assume the following regular files exist in your current directory '''ls'''a.txt b.txt c.txt 1.txt 2.txt 3.txt abc.txt work.txt webpage.html picture.png 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: '''ls a.txt b.txt c.txt 1.txt 2.txt 3.txt abc.txt work.txt'''a.txt b.txt c.txt 1.txt 2.txt 3.txt abc.txt work.txt 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": '''ls *.txt'''a.txt b.txt c.txt 1.txt 2.txt 3.txt abc.txt work.txt As you can see, the most recent Linux command you issued requires the least amount of keystrokes and therefore, it most efficient.   Special characters can be used to expand a general filename and use them if they match. You may have heard about “Wildcard Characters” – this is a similar concept. 
<br><br>
13,420
edits

Navigation menu