Bash shell is command language interpreter which read commands from the standard input or from a file and executes it. Shell scripting is useful tool when someone need to run multiple commands on shell repeatedly. In simple words shell scripting is defining all commands with or without conditions in a file and execute the same file as command.
Sample shell script with name bashscript is given to generate message “Welcome to shell scripting world.”
A. Edit a file using vi editor and add following lines in it.
[Linux server]#vi bashscript
!#/bin/bash
echo "Hi, This is my first shell script"
B. Make the script executable.
[Linux server]#chmod u+x bashscript
Or
[Linux server]#chmod 700 bashscript
C. Executing shell script.
[Linux server]#./bashscript
How to execute shell script as command ?
Just upload bashscript in any directory defined in the environment variable PATH. You can check directories defined in environment variable PATH using command.
[Linux server]#echo $PATH
Now on shell type script name on hash prompt and hit the enter. And you have execute shell script as command.
[Linux server]#bashscript
Script is executed as command.
If you have any question or need any shell script you can query the same as comment for this post. I will update your query or shell script in comment or will write post for the same asap.













