In a bash-script I need to check if the string
if [ $(echo $HEADER | cut -c 1-2) = '/*' ]
The problem is that the result of the command substitution is subject to file name generation. You need to quote that, as well as the expansion of
$HEADER in the command substitution.
if [ "$(echo "$HEADER" | cut -c 1-2)" = '/*' ]
Since you are using
bash, using the
[[ command (which can perform pattern matching) is a superior solution though, as Jahid has already answered.
if [[ $HEADER = '/*'* ]]