Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 07-20-2012
Registered User
 
Join Date: Jul 2012
Posts: 30
Thanks: 0
Thanked 1 Time in 1 Post
Display records between two search strings using sed

I have input file like

Code:
AAA
AAA
CCC
CCC
CCC
EEE
EEE
EEE
EEE
FFF
FFF
GGG
GGG

i was trying to retrieve data between two strings using sed.

Code:
sed -n /CCC/,/FFF/p input_file

Am getting output like

Code:
CCC
CCC
CCC
EEE
EEE
EEE
EEE
FFF

The above command retrieves the data till to the first occurence of the destination string (i.e., till 1st occurence off FFF record)
I need to search the records till last occurence.
Expected output is

Code:
CCC
CCC
CCC
EEE
EEE
EEE
EEE
FFF
FFF

Plz help on this query.

Last edited by Scrutinizer; 07-20-2012 at 07:32 AM.. Reason: code tags
Sponsored Links
    #2  
Old 07-20-2012
Registered User
 
Join Date: Jul 2012
Location: Chennai
Posts: 456
Thanks: 35
Thanked 57 Times in 55 Posts
DO NOT POST DUPLICATE POSTS!!!

I could see the same HERE...
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
query display number lines or records present in file only numeric value -without filename ksrivani UNIX for Advanced & Expert Users 3 07-22-2011 03:40 AM
Get records that does not contain particular strings bobbygsk Shell Programming and Scripting 1 01-14-2011 01:25 PM
extract strings from file and display in csv format grajp002 Shell Programming and Scripting 12 03-19-2010 01:38 AM
how to display records of file mishra_sk_in Shell Programming and Scripting 2 06-29-2007 04:43 AM
using cat and grep to display missing records jxh461 UNIX for Dummies Questions & Answers 4 01-13-2007 08:56 AM



All times are GMT -4. The time now is 10:47 AM.