Shell – How to print lines containing 3 words

shelltext processing

I would like to print lines in my file which containing 3 words seperated my 2 spaces.

for example:

AAA BBB CCC
BB AA
CCCCCCCC

only AAA BBB CCC sshould be printed.

I already use grep for it but I cant handle the spaces.

Best Answer

try

 awk 'NF==3' file.txt

this will grep line with 3 field (NF).

Related Question