Command Line in Linux Programming

input arguments into bash programming is like any normal command line program,where you can the arguments while you are executing.this can be done with special variables set aside for storing the arguments.the arguments are stored in variables with a number in the order of argument starting at 1 as $0 variable is the name of your script.


$0 - your script name
$1 - first argument
$2 - second argument
.
.
$# total argument
						    

Example


$vi demo.sh

echo "first argument : $1"
echo "second argument : $2"

echo "Command Line Argument"

if [ $1 -gt $2]
then
    echo "is greater"
fi	
						    
Share Share on Facebook Share on Twitter Share on LinkedIn Pin on Pinterest Share on Stumbleupon Share on Tumblr Share on Reddit Share on Diggit

You may also like this!