0

I have a huge text with multiple columns and rows and I want to keep the lines that consist one specific word (no matter in which column)...

(if possible I also like to have two separate specific words ( I can do this after making the first one if it is difficult))

2 Answers 2

4

Read man grep.

Do something like:

grep -w 'word' the_file
grep -E -w 'word1|word2' the_file
0

Below command you can use Tested and worked fine

 awk '{for(i=1;i<=NF;i++) {if (($i == "word1") || ($i == "word2")) {print $0}}}'  filename
1
  • What's NF? How to determine it (automatically)? Btw: This doesn't work for me (with white spaces as words), even with a specified number.
    – Nepumuk
    Nov 26, 2019 at 10:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .