The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM



View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 01-30-2008
Smiling Dragon's Avatar
Smiling Dragon Smiling Dragon is offline
Disorganised User
 
Join Date: Nov 2007
Location: New Zealand
Posts: 674
Post

So to clarify, you are wanting to only match lines that have (for example) 'kim' in the first or second field, but display the entire line where it's matched, right?

If so, you'll need a little bit of logic around the grep:
Code:
while read line ; do if echo $line | cut -d ' ' -f 1,2 | grep kim > /dev/null ; then echo $line ; fi ; done
Reply With Quote