I have the following script, which takes in a sentence from a user and then prompts the user whether they want it in all caps or lower case and echos that output, however the script is not working as I am facing the following error:
./casechanger.sh
Enter in your sentence, word or phrase: hello
Enter 1 to change the case to UPPER or 2 to change the case to LOWER: 1
./casechanger.sh: line 12: [1: command not found
./casechanger.sh: line 16: [1: command not found
Please select either 1 for upper or 2 for lower.
Here is my code:
read -p "Enter in your sentence, word or phrase: " WORD
read -p "Enter 1 to change the case to UPPER or 2 to change the case to LOWER: " CASE
if ["$CASE" == "1"]
then
echo $(cat "$WORD" | tr [:lower:] [:upper:])
elif ["$CASE" == "0"]
then
echo $(cat "$WORD" | tr [:upper:] [:lower:])
else
echo "Please select either "1" for upper or "2" for lower."
fi
I have tried multiple things including changing "$CASE" == "1" to "$CASE" -eq "1" etc.