Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sed syntax

Status
Not open for further replies.

FinnMan

Technical User
Feb 20, 2001
75
US

sed -e '/word/q' filename

The above deletes everything after the line containing 'word'. How do I change it so that it includes deleting the line containing word?

Thx,
./FM
 
sed -n '/word/,$p' filename

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Ouch --- that just took every line starting with line 'word' and duplicated it once.

./FM
 
Code:
awk '/word/{d=1}!d' filename
Let me know whether or not this helps.

If you have nawk, use it instead of awk because on some systems awk is very old and lacks many useful features. For an introduction to Awk, see faq271-5564.

 
strange - worked just fine under Solaris' stock 'sed'.

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Vlad, this is about removing from /word/ to end of file and you print from /word/ to end of file.

Try this:
Code:
sed '/word/,$d'

--------------------

Denis
 
ooops - my bad!

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top