Check occurence of a string with a variable number I have to check a certain condition, and that condition is that whenever somewhere in a certain url there is a line that states '[X] wrong' then return 'TestNotSuccesfull'. The X here could be '1','2,' etcetera.
I don't know how to make a statement that can check this, other then check for '1 wrong' OR '2 wrong' or '3 wrong', etc. There must be a better solution. Also because theoretically the X in 'X wrong' can lead up to multiple thousands...
Beneath the command line I made in bash that checks whether '1 wrong' occurs.
export result=`curl http://websiteABC.com | grep '1 wrong' | wc -l`; if [ $result -ge 1 ]; then echo "TestNotSuccesfull"; else echo "TestSuccesfull"; fi
Can anyone help me out?
PS, the string that has to be checked actually is part of '(...) right, X wrong, (...)'.
Aucun commentaire:
Enregistrer un commentaire