As my journey through Bash goes on, I'm still stuck on ridiculous stuff such as this script I just can't wrap my head around on:
#!/bin/bash
if [ $1 -gt 100 ]
then
echo "You typed a larger number"
if (( $1 % 2 == 0 ))
then
echo "And it's even an even number"
fi
Recently I was recommended to keep ShellCheck at hand's reach, and so I did, but it seems like its suggestions on how to improve this script doesn't work out either. Basically when I try to run it, I always get errors like "[: !=: unary operator expected" even when I try to quote $1 into "$1", which is also recommended by ShellCheck. Could anyone help me down? Thanks a lot in advance!
!=anywhere in your script. Second, you're missing the closingifwhich means you would get yet another error. Third, you are probably running the script without an argument so$1is undefined. But please don't make us guess: [edit] your question and make sure you show the actual code you use, explain how you launch it and the actual errors you get. – terdon Jun 18 '21 at 11:20