-1

I am calling a script with argument as "incr":

script.sh incr

I need to check if the argument passed is "incr" or not.

Also, "incr" can be any argument,not necessarily the first. For ex :

script.sh -l incr

Any general way to check if any argument is "incr" or not.

BMW
  • 42,880
  • 12
  • 99
  • 116
6055
  • 439
  • 1
  • 4
  • 14

1 Answers1

0

If you want to know if a particular argument is a string, the answer is "yes". All arguments are strings. If you want to know if an argument is a particular string, check it:

for arg; do
  if test "$arg" = incr; then
    echo incr is passed as an argument
  fi
done
William Pursell
  • 204,365
  • 48
  • 270
  • 300