0

I'm completely new with bash so I don't know how most things work.

I have this code which works when I enter the right type of arguments, but I need that the argument that goes with the -a flag can only be a string of letters and that the argument that goes with the -b flag can only be a string of numbers. Otherwise it should give an error message and exit.

while getopts a:b flag; do
    case "${flag}" in
        a) times=${OPTARG};;
        b) type=${OPTARG};;
    esac
done

java -jar TestSort.jar $times $type

should I create a function that checks every character of the argument string?

vale383
  • 73
  • 6

0 Answers0