I have a bash script that accepts input from the CLI using flag variables. Here's the script:
#!/bin/bash
d_flag=''
b_flag=''
c_flag=''
verbose='false'
print_usage() {
printf "invalid flag"
}
while getopts 'd:b:c:v' flag; do
case "${flag}" in
d) d_flag=${OPTARG} ;;
b) b_flag=${OPTARG} ;;
c) c_flag=${OPTARG} ;;
v) verbose='true' ;;
*) print_usage
exit 1 ;;
esac
done
echo $d_flag
echo $b_flag
echo $c_flag
exit 0
Here is the returned error:
user1@debian:/opt/scripts/# sh inputs.sh -d directory -b backupdir -c configdir -v
: not found2: inputs.sh:
: not found7: inputs.sh:
: not found10: inputs.sh: }
: not found11: inputs.sh:
: not found12: inputs.sh:
inputs.sh: 14: inputs.sh: Syntax error: word unexpected (expecting "in")
I cannot figure this out, as I have "in" in the syntax of the case statement. Can anyone help me figure this out?