uppercase to lowercase in bash on a mac
in bash, you can use nocaseglob
shopt -s nocaseglob
for file in *.jpg *.jpeg *.gif
do
echo "$file"
done
#turn off
shopt -u nocaseglob
in general to convert cases, various ways
echo "stRING" | awk '{print toupper($0)}'
echo "STRING" | tr "[A-Z]" "[a-z]" # upper to lower
echo "StrinNG" | sed 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' #lower to upper
this is built into bash:
to convert $y into uppercase:
y="this Is A test"
echo "${y^^}"
and to convert $y into lowercase:
y="THIS IS a TeSt"
echo "${y,,}"
$ echo 'this IS some TEXT' | tr '[:upper:]' '[:lower:]'
this is some text