0

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.

2

try

 awk 'NF==3' file.txt

this will grep line with 3 field (NF).

2
grep -Ev '^([^ ]* *){2}$|( .*){3}' \
<<""
aaaa 
aaaa bbbb
aaaa bbb ccc
aaaa bbb  ccc
aaaa bbb cccc dddd

aaaa bbb ccc

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.