I have a bash script that stores the output of a file comparison. The variable becomes something like: thing="/path/to/file - differ: byte 2, line 3".
In later lines I want to check that thing is not empty. However, when I try comparing them, it interprets thing as a command and not simply as a string.
My code is somewhat as follows:
#!/bin/bash
thing="/path/to/file - differ: byte 2, line 3"
if ["$thing" != ""]; then
echo
echo "Something went wrong"
else
echo "Everything worked"
fi
Rather than saying thing is not an empty string, I get an error message that says something like
bash: [/path/to/thing - differs: byte2, line 3: No such file or directory.
How can I ensure that a comparison is happening between strings and that thing is not being interpreted as a command?