Handling arguments in bash

#!/bin/bash<br></br>
echo Total Number of Arguments Passed: $#<br></br>
i=1;<br></br>
for var in "$@"<br></br>
do<br></br>
echo "Argument $i is $var"<br></br>
let i=$i+1;<br></br>
done```

 

**Check if expected number of arguments is passed to the script:**

 

EXPECTED_ARGS=2 E_BADARGS=65 if [ $# -ne $EXPECTED_ARGS ] then   echo "Usage: `basename $0` {arg}"   exit $E_BADARGS fi