The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com




View Single Post in the UNIX and Linux 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 Forum Advisor  
Disorganised User
  
 

Join Date: Nov 2007
Location: New Zealand
Posts: 922
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