There are some predefined variables which holds some data related to arguments in shell.
$# – to print arguments size.
$* and $@ – to print all arguments that are passed to a shell script(we can use the in loops – for or while).
Examples:
My script t.sh contains following code.
$ cat t.sh
echo “No.of args: $#”
echo “args: $*”
echo “args: $@”
Just execute the t.sh script.
$ sh t.sh 1 2 3 4
output:
No.of args: 4
args: 1 2 3 4
args: 1 2 3 4
-Sany