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


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 06-22-2012
Registered User
 
Join Date: Sep 2011
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
Help with search criterai

Hi ,

I have requirement... where in there are headers in the file and i need to pick the records right below them...

Example;

Code:
Qwerty Apple
10 20 30'
30 40 50
50 60 70
Qwerty Mango
40 50 60
76 86 98
80 59 67
Qwerty banana
77 66 99
77 99 100

Now, my search criteria shud be based on apple,mango and banana and i need to pick the records beneath the header and the headers shouldn't be present in the file.

Last edited by vbe; 06-22-2012 at 09:07 AM.. Reason: code tags
Sponsored Links
    #2  
Old 06-22-2012
elixir_sinari's Avatar
Gotham Knight
 
Join Date: Mar 2012
Location: India
Posts: 1,370
Thanks: 87
Thanked 476 Times in 456 Posts

Code:
sed '/^Qwerty/d' file

Sponsored Links
    #3  
Old 06-22-2012
complex.invoke's Avatar
Registered User
 
Join Date: Nov 2009
Location: BeiJing China
Posts: 234
Thanks: 6
Thanked 17 Times in 8 Posts

Code:
sed -n '/[0-9]/p' infile

    #4  
Old 06-22-2012
Registered User
 
Join Date: Sep 2011
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
sed '/^Qwerty/d' file ......Works fine


But what if say , i do not want the records below Qwerty Mango???? How can we handle this????


Moderator's Comments:
Please use next time code tags for your code and data, you are not far to get a temporary ban...

Last edited by vbe; 06-22-2012 at 09:11 AM.. Reason: icode tags
Sponsored Links
    #5  
Old 06-22-2012
elixir_sinari's Avatar
Gotham Knight
 
Join Date: Mar 2012
Location: India
Posts: 1,370
Thanks: 87
Thanked 476 Times in 456 Posts

Code:
sed '/^Qwerty Mango/q' file

Sponsored Links
    #6  
Old 06-22-2012
Registered User
 
Join Date: Sep 2011
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
it doesnt work as expected...get the same result as
Code:
 sed '/^Qwerty/d' file


Last edited by vbe; 06-22-2012 at 09:43 AM..
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Binary Search Tree Search problem meredith1990 Programming 1 02-27-2012 10:23 AM
sed help - search/copy from one file and search/paste to another ncwxpanther Shell Programming and Scripting 5 08-21-2011 10:56 AM
Search files with specfic extention and later search content lovi_v UNIX for Advanced & Expert Users 2 07-14-2008 12:05 PM
Perl: Search for string on line then search and replace text Crypto Shell Programming and Scripting 4 01-04-2008 09:24 AM
Advanced Search Problems.. Search by User Name Neo Post Here to Contact Site Administrators and Moderators 1 05-19-2003 12:28 AM



All times are GMT -4. The time now is 10:20 PM.