Programming Tutorials

Command line arguments in Shell Script

By: Vivek G in Linux Tutorials on 2011-01-29  

This shell script shows how to accept command line arguments in shell scripts. In this example it accepts two numbers and adds them.
if [ $# -ne 2 ]
    echo "Usage - $0   x    y"
    echo "        Where x and y are two nos for which I will print sum"
    exit 1
    echo "Sum of $1 and $2 is `expr $1 + $2`"

Add Comment

* Required information


No comments yet. Be the first!

Most Viewed Articles (in Linux )

Latest Articles (in Linux)