WriteBash - In this article, what will we learn about expansion in Linux? What does it do when we type the command on the terminal?
Throughout this series, we only use a single
echo command. This command is quite simple and probably everyone knows, it will print out the text content that we type from the keyboard.
What is the expansion?
Every time we type the command and press the enter key, bash will do some processing on the text before actually executing the command we typed.
Maybe, you saw this in the previous examples but didn’t notice. For example, characters
* for example. When we type
echo * bash has processed this
* before executing the echo command.
This processing is expansion.
Example of expansion
You know, the echo command is a builtin shell, it’s very simple. For example:
$ echo My name is Danie
Next, we try to type the
echo command with the
$ echo *
Recommended Reading: Get help for shell builtins with help command
You can see the result in the image above, why the
echo command does not print the
* character on the screen. Instead, it prints a list of files in the directory.
We will return a term that is
wildcard, you know, the character
* here represents any character in the filename. But in the
echo command there is no mention of this.
So what happened?
Simply explained, the shell has expanded the
* character to something else (here, it has expanded the
* character to the names of the files and subdirectories present in the current directory) before it executes the
For the small example in the article, you can already grasp expansion in linux. Each time you type a command, it will process the text before it sends the command to the shell to execute. In the next article, we will learn more about expansion.If you liked this article, then please subscribe to our YouTube Channel for more video tutorials. You can also find us on Twitter and Facebook.
If you appreciate what we share in this blog, you can support us by:
- Stay connected to: Facebook | Twitter | Google Plus | YouTube
- Subscribe email to recieve new posts from us: Sign up now.
- Start your own blog with SSD VPS - Free Let's Encrypt SSL ($2.5/month).
- Become a Supporter - Make a contribution via PayPal.
- Support us by purchasing Ribbon Lite Child theme being using on this website.
We are thankful for your support.