Linux Bash How to Define, Use Shell Variables

RSS
FACEBOOK
FACEBOOK
PINTEREST
PINTEREST
LINKEDIN
INSTAGRAM

[rps-include post=6835]

Variables are programming part of the bash and very useful. Without variables bash will be very inefficient shell. Variables are used by bash itself, running applications, daemons, X (graphic) server and for a lot of things.

Define Variable

Defining variables are easy in bash, just variable and data is enough. echo is used to print variables into terminal. With equal sign variable values are set. As you see page, Page, PAGE are different variables this means bash is case sensitive.

Delete/Undefine Variable

Sometimes we don’t need variables that are created before and we want simple delete them. unset keyword is used to delete variable completely.

Change Variable Value

There is no extra effort to change existing variable value. It is just like creating new variable

Concatenate Variables

To join variables together just put them together. In the second echo we put one space between hello and poftut variables which effects printed string too.

We create two variables named hello and poftut. Than we echo both by joining together without any operator.In the second echo we put single space between them and then join all of them together.

LEARN MORE  Linux Tee Command Tutorial with Examples For Stdout Management

[rps-include post=6835]

RSS
FACEBOOK
FACEBOOK
PINTEREST
PINTEREST
LINKEDIN
INSTAGRAM

Leave a Reply

Your email address will not be published. Required fields are marked *

Enjoy this blog? Please spread the word :)