Shell Script to print command line arguments Type 2
Program
#!/bin/sh
n=$#
echo "Number of command line arguments:" $n
if [ $n -gt 0 ]
then
echo "List of arguments"
for arg in $@
do
echo "$arg"
done
else
echo "No arguments"
fi
Output
$ ./print-command-line-2.sh hello world how are you?
Number of command line arguments: 5
List of arguments
hello
world
how
are
you?