Help with search criterai

Thread Tools Search this Thread
# 1  
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...

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 10:07 AM.. Reason: code tags
# 2  
sed '/^Qwerty/d' file

# 3  
sed -n '/[0-9]/p' infile

# 4  
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:
Mod Comment 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 10:11 AM.. Reason: icode tags
# 5  
sed '/^Qwerty Mango/q' file

# 6  
it doesnt work as expected...get the same result as
 sed '/^Qwerty/d' file

Last edited by vbe; 06-22-2012 at 10:43 AM..

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Science: Computers
Difficulty: Medium
AMD created the first consumer 64-bit processor.
True or False?

10 More Discussions You Might Find Interesting

1. What is on Your Mind?

YouTube: Search Engine Optimization | How To Fix Soft 404 Errors and A.I. Tales from Google Search

Getting a bit more comfortable making quick YT videos in 4K, here is: Search Engine Optimization | How To Fix Soft 404 Errors and A.I. Tales from Google Search Console (0 Replies)
Discussion started by: Neo
0 Replies

2. UNIX for Beginners Questions & Answers

How to use a grep search to search for a specific string within multiple directories?

Lets say I have a massive directory which is filled with other directories all filled with different c++ scripts and I want a listing of all the scripts that contain the string: "this string". Is there a way to use a grep search for that? I tried: grep -lr "this string" * but I do not... (3 Replies)
Discussion started by: Circuits
3 Replies

3. What is on Your Mind?

Updated Forum Search Index Min Word Length to 2 Chars and Added Quick Search Bar

Today I changed the forum mysql database to permit 2 letter searches: ft_min_word_len=2 I rebuilt the mysql search indexes as well. Then, I added a "quick search bar" at the top of each page. I have tested this and two letter searches are working; but it's not perfect,... (1 Reply)
Discussion started by: Neo
1 Replies

4. What is on Your Mind?

Search Results (Search, New, and Today's Topics) Animation Switch

Hey, I added an animation switch on the search results page; so by default the thread previews are off, but if you want to look at them, just click on the green button and the thread previews will turn on (and back off). See image and attached animation: ... (1 Reply)
Discussion started by: Neo
1 Replies

5. UNIX for Dummies Questions & Answers

Search file and print everything except multiple search terms

I'm trying to find a way to search a range of similar words in a file. I tried using sed but can't get it right:sed 's/\(ca01\)*//'It only removes "ca01" but leaves the rest of the word. I still want the rest of the information on the lines just not these specific words listed below. Any... (3 Replies)
Discussion started by: seekryts15
3 Replies

6. Shell Programming and Scripting

Search pattern on logfile and search for day/dates and skip duplicate lines if any

Hi, I've written a script to search for an Oracle ORA- error on a log file, print that line and the .trc file associated with it as well as the dateline of when I assumed the error occured. In most it is the first dateline previous to the error. Unfortunately, this is not a fool proof script.... (2 Replies)
Discussion started by: newbie_01
2 Replies

7. Shell Programming and Scripting

Search: find current line, then search back

Hello. I want to find a line that has "new = 0" in it, then search back based on field $4 () in the current line, and find the first line that has field $4 and "last fetch" Grep or Awk preferred. Here is what the data looks like: 2013-12-12 12:10:30,117 TRACE last fetch: Thu Dec 12... (7 Replies)
Discussion started by: JimBurns
7 Replies

8. Shell Programming and Scripting

Perl - start search by using search button or by pressing the enter key

#Build label and text box $main->Label( -text => "Input string below:" )->pack(); $main->Entry( -textvariable => \$text456 )->pack(); $main->Button( -text => "Search", -command => sub { errchk ($text456) ... (4 Replies)
Discussion started by: popeye
4 Replies

9. Shell Programming and Scripting

Perl - use search keywords from array and search a file and print 3rd field when matched

Hi , I have been trying to write a perl script to do this job. But i am not able to achieve the desired result. Below is my code. my $current_value=12345; my @users=("bob","ben","tom","harry"); open DBLIST,"<","/var/tmp/DBinfo"; my @input = <DBLIST>; foreach (@users) { my... (11 Replies)
Discussion started by: chidori
11 Replies

10. Shell Programming and Scripting

Perl: Search for string on line then search and replace text

Hi All, I have a file that I need to be able to find a pattern match on a line, search that line for a text pattern, and replace that text. An example of 4 lines in my file is: 1. MatchText_randomNumberOfText moreData ReplaceMe moreData 2. MatchText_randomNumberOfText moreData moreData... (4 Replies)
Discussion started by: Crypto
4 Replies

Featured Tech Videos