Hello,

I have a data file that has names of varying lengths that are listed in columns. ie:

Ranjit Singh        Dean Johnson   
Ken Whillans       Karen Thompson 
Peter Robertson  Rich Gardener  
Sandeep Jain      Ken Whillans   
John Thompson   Cher           
Cher                 Karen Patel    
John Jacobs       Davinder Singh 
Dean Johnson     Sandeep Jain   
Karen Thompson John Thompson  
Rich Gardener     Peter Robertson
Karen Patel        Ranjit Singh

I'm trying search the left column and print out the corresponding with it on the right. i.e A search for 'ohn' would only print out:

John Thompson   Cher 
John Jacobs       Davinder Singh 
Dean Johnson     Sandeep Jain

(All the names should be in perfect column columns with the first letters lining up with each other)

I've tried cutting each into temp files and grep'ing those files, but I can't find out a way to only output the info that I want.

Any help would be appreciated.

Recommended Answers

All 2 Replies

so you want this output

John Thompson   Cher 
John Jacobs       Davinder Singh 
Dean Johnson     Sandeep Jain

to look like this

John Thompson   Cher 
John Jacobs     Davinder Singh 
Dean Johnson    Sandeep Jain

so you want this output

John Thompson   Cher 
John Jacobs       Davinder Singh 
Dean Johnson     Sandeep Jain

to look like this

John Thompson   Cher 
John Jacobs     Davinder Singh 
Dean Johnson    Sandeep Jain

Well yes. That would be the result of searching for "ohn".

I want to search the left column for something, and print out all rows that contain the search string in the left column.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.