Pathname Expansion

The mechanism by which wildcards work is called pathname expansion. you can use wildcard after the filename or before the filename.

echo filestarting_name*

Example:

 

Bash Pathname Expansion in Linux

When you type a command and press enter, bash performs several processes upon the text before carrying out our command as a command. The process that makes this happen is called expansion. For example, suppose you use the echo command for standard output.

echo hi
Output hi

If you use echo with asterisk wildcard echo will print your directory. Suppose you have two files in the current working directory. The first file name is file1.txt and file2.txt then you will use echo with asterisk wildcard then It will print your directory name.

Example:

 

Types of Expansion

  • Pathname Expansion
  • Tilde Expansion
  • Arithmetic Expansion
  • Brace Expansion
  • Parameter Expansion
  • Command Substitution

Similar Reads

Pathname Expansion

The mechanism by which wildcards work is called pathname expansion. you can use wildcard after the filename or before the filename....

Tilde Expansion

“~” Tilde Represents the home directory in the Linux system. Use tilde as an expansion...

Arithmetic Expansion

The Bash shell allows arithmetic expansion. This allows us to perform a Linux shell as a calculator....

Brace Expansion

With this Expansion, you can create multiple text strings from a pattern containing braces...

Parameter Expansion

If you know any programming language basics then parameter expansion is easy for you because it’s similar to a data variable. In Linux, You can define a variable like this...

Command Substitution

Command substitution  uses the output of a command as an expansion...

Quoting

Quoting helps to control Linux command expansion...

Double Quotes

Double quotes stop the expansion. If you place characters inside of double quotes, all special characters used by the shell have their special meaning and are treated as ordinary characters. This means some expansions do not work in double quotes example: pathname expansion, tilde expansion, and brace expansion are suppressed....

Single Quotes

If you want to suppress all expansions. You can use single quotes....

Escaping Characters

Sometimes we want to quote a single character. To do this, we can precede characters with a backslash called escape characters....

Backslash Tricks

Let’s take an example, On our desktop, we have a “Backslash Folder” in this folder we also have 1 to 50 folders and the first Folder also has 1 to 50 fifty folders. Sometimes It’s very tedious work to type every folder name so we can solve this problem by backslash and asterisk. See the Syntax...

Contact Us