Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

How do I filter by third column of the following file

list.txt [[ list of people ]]

billy baxter - @baxter - [email protected]
james woods - @woods - [email protected]

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.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

You can use awk to search by the third column

awk -F"-" '$3 ~ /@woods.com/' list.txt
share|improve this answer
    
thanks it worked first off. :) –  user1827093 May 1 at 0:20
    
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 at 0:38

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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