1

How do I filter by third column of the following file

list.txt [[ list of people ]]

billy baxter - @baxter - b.baxter@woods.com
james woods - @woods - j.woods@someother.com

I currently have

cat list.txt | grep @woods > results.txt

The prob is the second column also has @ symbol so I cant search for @woods. Also I rather not search for @... or regex as there may be a secondary email2 col which I don’t want to filter by

I simply want to filter and only get lines by the third col. Ideally somehow to filter only in the third col, but retrieve whole lines.

1

You can use awk to search by the third column

awk -F"-" '$3 ~ /@woods.com/' list.txt
  • Also in my script script.sh it wouldnt work, I removed the tilda ~ and it did. Not sure just thought Id mention it – user1827093 May 1 '15 at 0:38

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.