I am trying to create a script that lowercases/uppercases files or directories.
modify [-r] [-l|-u] <dir/file names...>
I am currently using getopts to check for flags. However, I can't run my command like that modify -rl to lowercase recursively my dir / files.
(edit) The code:
#!/bin/bash
FLAGS=""
if [ $# -eq 0 ]
then
echo -e "No arguments supplied. \nPlease supply an argument.For more information use -h."
else
while getopts "rluh" opt
do
case $opt in
r)
FLAGS+=r
;;
l)
FLAGS+=l
;;
u)
FLAGS+=u
;;
h)
FLAGS+=h
;;
*)
echo "Unrecognized argument. Please enter -h for information"
esac
done
fi
if [[ "$FLAGS" == "l" && "$2" -eq 0 ]]
then
echo "file to modify $2"
elif [[ "$FLAGS" == "h" && "$2" -eq 0 ]]
then
echo "Some info"
fi
exit 0
getoptsor about how to implement lowercasing of filenames? In either case, you have not shown any actual code.