I'm doing a script in which I need to test a string and based on its result I'll decide if I go further or not.
The command below works fine (if the string starts with "Clean" it will print 1, otherwise 0).
echo | awk ' {print index("'"${task}"'", "Clean")}'
What I'm trying to do is to use the AWK with IF in a BASH script. Based on this post I did the following:
idx=$(awk '{print index("'"${task}"'", "Clean")}')
echo $idx
if [ "$idx" == "0" ]; then
echo hello
fi
As I said, when I run the script it prints "0", but the second "echo" doesn't print anything, and of course the if doesn't works either.
Can anyone help me?
TIA,
Bob