I have the following bash code that is copied and pasted from a "bash cookbook" (1st edition):
#!/bin/bash VERBOSE=0; if [[ $1 =-v ]] then VERBOSE=1; shift; fi
When I run this (bash 4.0.33), I get the following syntax error:
./test.sh: line 4: conditional binary operator expected ./test.sh: line 4: syntax error near `=-v' ./test.sh: line 4: `if [[ $1 =-v ]]'
Is it as simple as a typo in a bash cookbook, or is there a version incompatibility or something else here? What would be the most obvious solution? I tried various combinations of operator change, but I am not very good at bash scripts.
source share