How to define variable in shell script on CentOS and RHEL 6/7 step by step guide


How to define variable in  shell script on CentOS and RHEL 6/7  step by step guide


In this article we will learn how to define variable in shell script and execute it on CentOS and RHEL linux sytem.

Shell script is very powerful language for a system admin to execute the daily basic staff.

Variable store some information and data which will be used rest of the shell program.

How to define variable shell script on linux system

===================================================================
Now we are going to write one small shell script program to understand how to define variable in  shell script on the linux system  .

First we create one empty file named variable.sh using the below command.

#touch variable.sh

After creating empty file we enter the below line in the file.

#!/bin/bash
website=”techrideradmin”
echo welcome to $website

note: we shoule use #!/bin/bash to identify this script only run in bash shell not the other shell and when define viable don’t use $ sign and when print the output the we have to put $ sing to getting the output.

How to execute the shell script program

====================================================================
To execute this program we need to execute the below command.

[root@localhost ~]# sh variable.sh

After execute the above command we can find the below output..

Output:
welcome to “techrideradmin”
How to define variable in  shell script on CentOS and RHEL 6/7  step by step guide
How to define variable in  shell script on CentOS and RHEL 6/7  step by step guide


That’s all. If this article is helpful please share it!!!!







Please Donate To Bitcoin Address: [[address]]
Donation of [[value]] BTC Received. Thank You.
[[error]]
SHARE

Admin

  • Image
  • Image
  • Image
  • Image
  • Image
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment