Okay so i have a variable called search which holds the string “Find this Code – Now”. I want to search for that code and if it finds it the system would reply with true or something on those lines, if it doesn’t then it just exits the script with error.
I tried to use grep but i couldn’t figure out how to cut only what was searched for so i could run an if else statement
You can use the
-qswitch and check the exit status of grep, i.e. something likegrep -q $var <file> && echo "true".