Automatic mode ( -a ) (default):This mode shoudnt ask any input from user and should run automatically.
Interactive mode (-i) : This mode should ask user for input .
Initially i m trying to concentrate on automatic mode which is by default.
I have used getopts method to deal with command line arguments. However this might restricted to bash script because of getopts method.
Method used in program.
if [ $# -eq 0 ]
echo "Automatic Mode Selected"
while getopts ai option 2>/dev/null
case "$option" in
a) echo "Automatic Mode Selected";;
i) echo "Interacive Mode Selected";;
?) echo "Please select proper option"
echo list of available options
-a automatic -i interactive ;;
However I will also post universal method to establish the same task.
while [ "$#" -gt 0 ]; do
case "$1" in
: do something
: do something with $2
# this could be an invalid option or just a file
# if no file is expected, do something like:
echo "invalid option or argument: $1"
Please Leave us with your comments and Queries/Suggestions.
I will try to reply asap.