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 > Shell Programming and Scripting
.
google unix.com



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

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
URGENT: Script/Function needed to read text property files in block wise ysreenivas Shell Programming and Scripting 7 05-11-2009 04:08 AM
need one liner to edit this text... ilan Shell Programming and Scripting 3 04-24-2008 06:25 AM
Building Full-Text Search Applications with Oracle Text iBot Oracle Updates (RSS) 0 04-06-2008 06:10 AM
Edit and insert character in a text file negixx Shell Programming and Scripting 3 06-10-2005 02:36 PM
Urgent answer needed, please: help with a text editor MtFR UNIX for Dummies Questions & Answers 4 05-22-2004 01:05 PM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 07-11-2007
stevefox stevefox is offline
Registered User
  
 

Join Date: Aug 2005
Posts: 115
Question SED text edit help needed

Could someone please tell me how to delete all lines above a line which contains a particular string? (possibly using SED command)
I know how to do this if the target string appears in only one line of file but when it appears in multiple lines it only deletes from the first line which the string appears to the top line. I want it to delete from the last line which the string appears to the top line.


e.g I have the file below which contains 8 lines:

Code:
$ cat file.txt
a
b
c
d
a
b
c
d
$
I want to delete everything above the line with the charater "b" to get the below:

Code:
c
d
I tried with the command below but it only deleted line from the top to the first line which contains the charater "b"

sed '1,/b/d' file.txt

Regards,
Steve
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:33 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0