I have the following line as part of a much bigger bash script:
if [ `packages/TinySVM-0.09/bin/svm_learn 2>&1| grep TinySVM | wc -l | cut -c0-7 | sed 's/^ *//g'` -eq 1 ]
upon running the script, I get:
./install.sh: line 219: [: -eq: unary operator expected
Where line 219 is the line above. Any suggestions for a fix?
You can run your command without any additional syntax. For example, the following checks the exit code of grep to determine whether the regular expression matches or not:
if ! grep -q "$word" /usr/share/dict/words
then
echo "Word $word is not valid word!"
fi