Shell scripts are compiled ---- This is a wrong statement.
a programming language must provide the following services
- comments,
- variables,
- conditional commands, and
- repeated action commands.
These extra services are provided by the shell. Different shells use different syntax for these services. That means Shell is a programming language.
Shell scripts are not compiled, rather, they are interpreted and executed by the shell itself.Shell scripts can also call compiled programs.
Now, Shell scripts can accept arguments.
We'll try to prove it by passing argument in command line.
Create a file named filename.sh
Here it is arg.sh
in the script write this program
then write
sh arg.sh
sukanya
das
cse
it'll give output as
Now, what's going on the program?
in the shell script(arg.sh)
$# ---> Store count of command line arguments
$* -----> Store all command line arguments
$0 -----> Store name of script itself
$1 ----> Store first command line argument
$2 ----> Store second command line argument
$3 -----> Store third command line argument
Now, when we write
sh arg.sh
sukanya
das
cse
$1 takes sukanya as 1st parameter
$2 takes das as 2nd parameter
$3 takes cse as 3rd parameter
So, Shell scripts can accept arguments.