13,420
edits
Changes
→Filename Expansion
As shown in the diagram on the right, when the ls command is issued with a filename expansion symbol (like *), the Bash shell searches for files that match the symbol (in this case all filenames that end with the extension ".txt") and expands the argument using the wildcards with those filenames as separate arguments. You do not see this happen in the shell, it is a process that occurs "behind the scenes".
Below are the most common Filename Expansion symbols and how they are used for filename expansion:
<table cellpadding="5"><tr><th style="border-bottom: 1px solid black;text-align:left;">Filename Expansion Symbol</th><th style="border-bottom: 1px solid black;text-align:left;">Purpose</th></tr><tr><td>'''*'''</td><td>Asterisk (*) to represent '''0 or more characters'''</td></tr><tr><td>'''?'''</td><td>Question mark (?) to represent '''exactly one character (any character)'''</td></tr><tr><td>'''[ ]'''</td><td>Square brackets ([ ]) to represent and match for the '''character enclosed within the square brackets'''.<br>It represents ONLY ONE character - '''its like a Question Mark (?) but with restrictions'''</td></tr><tr><td>'''[! ]'''</td><td>Square brackets containing an exclamation mark immediately after the open square bracket ([! ])<br>to represent and match and '''OPPOSITE''' character for the character enclosed within the square brackets.</td></tr></table>