What is a shell script?
Shell script is a group UNIX commands grouped together in a file. Shell scrips are interpreted and not compiled like C or C++. The difference between interpreter and compiler is that former executes line by line but later executes the entire script by loading them in memory.
When SHELL scripts are executed, a separate child process is created by the SHELL.
Example of SHELL Script:
#!/bin/sh
echo "Hello World!"
Lets save this script as hello.sh. This is a simple SHELL script which will just print "Hello World!" on the console.
The first line of this script is interpreter line, i.e. we provide the path of interpreter in this case bourne shell to the script. This path is prefixed with #!.
If you want to use some other interpreter like BASH shell or KORN SHELL etc, you might need to provide their path accordingly in the first line of the script.
Execution of the SHELL script:
Shell script is a group UNIX commands grouped together in a file. Shell scrips are interpreted and not compiled like C or C++. The difference between interpreter and compiler is that former executes line by line but later executes the entire script by loading them in memory.
When SHELL scripts are executed, a separate child process is created by the SHELL.
Example of SHELL Script:
#!/bin/sh
echo "Hello World!"
Lets save this script as hello.sh. This is a simple SHELL script which will just print "Hello World!" on the console.
The first line of this script is interpreter line, i.e. we provide the path of interpreter in this case bourne shell to the script. This path is prefixed with #!.
If you want to use some other interpreter like BASH shell or KORN SHELL etc, you might need to provide their path accordingly in the first line of the script.
Execution of the SHELL script:
No comments:
Post a Comment