2

I have a .txt file in this format:

 USER:EMAIL:PHONE

but some lines only have

 USER:EMAIL

I want to extract only the lines containing 3 fields, example

 USER:EMAIL:PHONE
3

This will help:

awk -F':' 'NF==3{print}{}' file
  • Thank you very much it worked :) I'll green tick u once time expires haha – Thomas Bishop Mar 3 '17 at 7:11
  • 2
    awk -F: 'NF==3' file also works, less typing :-) – steve Mar 3 '17 at 11:19

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.