Suppose I have variable "x" in bash. How can I test if it's some number?
I tried if x=5; then echo "it is 5"; fi
but that doesn't work,
then I tried if x==5; then echo "it is 5"; fi
but that also doesn't work,
then I tried if [x==5]; then echo "it is 5"; fi
but that also doesn't work,
then I tried if [[x==5]]; then echo "it is 5"; fi
but that also doesn't work,
then I tried if [[x=5]]; then echo "it is 5"; fi
but that also doesn't work,
then I tried if [x=5]; then echo "it is 5"; fi
but that also doesn't work,
then I tried if [x -eq 5]; then echo "it is 5"; fi
but that also doesn't work,
then I tried if [[x -eq 5]]; then echo "it is 5"; fi
and it finally worked.
I am lost. Bash seems to be hell. Why so many ways didn't work? And only the last one did?
Can't bash adopt if x==5; then ...; fi
syntax?
Thanks, Boda Cydo