mardi 29 septembre 2020

Is there a way to check for whether a substring is in a string in a Linux/Bash script with a short line usable in a conditional if statement?

I'm using

if[ "$wordCount" -gt 10 ]

To check if there are more than 10 words in the line, but how can I also check if a specific string, say "Brown Cow" is also within the line?

So the conditional should only work if the line has a wordCount of over 10 and contains the string "Brown Cow" within the $line string. Is there a way to do that within Linux/Bash? Or will I need a multi-line or different conditional like case to do it?

Aucun commentaire:

Enregistrer un commentaire