Bash Shell Script – 1

Bash Shell Script - 1

Bash shell scripting is collections of Linux commands in a single file and we should know where and when to use the command. Its mandatory to know all the basic commands for bash shell scripting.

Execute permission is must to run the script.

Using below command will add the execute permission to a file.

#chmod +x testscript.sh

Here am using testscript.sh file for simple script.

Now check using “ll” command whether the permission has been added or not.

#ll | grep -i testscript.sh

We can use three methods to execute the bash shell script.

1. ./testscript.sh
2. sh testscript.sh
3. bash testscript.sh

Here am writing script to display a string.
Echo command will do simple printing whatever we are giving with double quotes.

Already i have created testscript file using vi editor.

#vi testscript.sh

Now will write a script to display Current logged in user, date and Count of users logged in.
Use the vi editor to create script file.

#vi testscript1.sh



type the below set off commands to create this script.

Save and exit from the file.

change the permission using chmod command.

#chmod +x testscript1.sh

Now run the script and check for the output.



like above will create bash shell scripts for our requirements.
Will see some other examples in next post.


Leave a Reply

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