Using command line argument in Shell Script
#!/bin/sh
#Shell script to demonstrate Command Line Arguments
# define variables to be used
i=1
fact=1
# simple loop to use the command line arguments
# Finding the factorial of a number supplied with the
# command line argument $1
while test $1 -ge $i
do
fact=`expr $fact \* $i`
i=`expr $i + 1`
echo $fact
done
echo "The Factorial Of $1 Is: $fact"
while [ #1 -ge 1 ];
do
echo $1
shift
done
Like it on Facebook, Tweet it or share this article on other bookmarking websites.