lundi 24 février 2020

Checking a word in a file to do a statement by Shell

I have this file:

wwsex gender wwmm mother 
mm ccmother ccfather 

And I need to check if a file contains a specific word (exactly the same, identic) to do the statement considering just the second line. I tried this:

if grep -q ww 'my.file'; then
echo "correct - just a simple example" >> file
fi 

But it's wrong, this way I checked all the file and consider the wwsex and wwmm to do the statement. But I need to be specific in the word and the line.

Aucun commentaire:

Enregistrer un commentaire