i'm trying to use getopts to make a command: actu -c [credits to add] to add a value to a variable that is on a .txt file but I don't understand what i'm doing wrong:
#!/bin/bash
set -e
set -u
set -o pipefail
while getopts 'c:' OPTION; do
case "$OPTION" in
c)
c="$OPTARG"
value=$(<cred.txt)
value=$((value+c))
echo "There were added: "$c" credits, total: "$value""
echo $value>cred.txt
;;
?)
echo "actu [-c]" >&2
exit 1
;;
esac
done
shift "$((OPTIND -1))"
Any help would be apreciated!