You probably are aware of variables in Bash shell scripting. .

Like other programming and scripting languages you use variables to store the data and then reference them later in future commands.

And it will print quotHello Linux Handbookquot.

Outside of the example above thereaposs also a surprisingly large amount of things you can do with variables such as filling in a default value when the variable isnapost set and assigning multiple values to a single variable.

Let me show you these unusual and advanced usage of variables in bash scripting.

Excluding the above example the most common type of variable youaposll find in Bash is arrays.

The above example assigns both Linux Handbook and Itaposs FOSS as the values for the name variable.

How do you go about accessing each value though.

If you run echo name youaposll see that it prints the first value Linux Handbook. To access the other values youaposll need to use a different syntax for variables.

...

Read Full Post

News Link: https://linuxhandbook.com/variables-bash-script/.

Linux Chatter is a news aggregator service that curates some of the best Linux, Cloud, Technical Guides, Hardware and Security news. We display just enough content from the original post to spark your interest. If you like the topic, then click on the 'read full post' button to visit the author's website. Use Linux Chatter to find content from amazing authors!

Note: The content provided has been modified and is not displayed as intended by the author. Any trademarks, copyrights and rights remain with the source.

Disclaimer: Linux Chatter sources content from RSS feeds and personal content submissions. The views and opinions expressed in these articles are those of the authors and do not necessarily reflect those of Linux Chatter.