LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Tags used in this thread
Popular LQ Tags , , , , ,

Reply
 
Thread Tools
Old 04-19-2008, 03:32 PM   #1
LuciusHunt
LQ Newbie
 
Registered: Apr 2008
Location: Romania
Posts: 4
Thanked: 0
delete lines with sed


[Log in to get rid of this advertisement]
i have to check the first 30 lines of a file with sed and to delete those lines which contain a specific word or phrase.

sed -i '/specword/d' filename

this deletes all the lines in a file, but i want to check only the first 30.
how should i do this?


thanks a lot !
LuciusHunt is offline  
Tag This Post , , , , ,
Reply With Quote
Old 04-19-2008, 03:40 PM   #2
druuna
Senior Member
 
Registered: Sep 2003
Location: netherlands
Distribution: lfs
Posts: 3,269
Thanked: 78
Hi,

Try this:

sed '1,30{/specword/d}' infile

Hope this helps.
druuna is offline     Reply With Quote

Reply

Bookmarks


Thread Tools

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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
sed or grep : delete lines containing matching text raj000 Linux - General 12 08-02-2009 10:44 PM
Delete specific Range of lines Using sed , awk, grep etc. joyds219 Linux - Newbie 4 03-28-2008 09:59 AM
Insert and delete lines at the end of a file using sed DriveMeCrazy Programming 1 01-05-2007 02:45 AM
awk/gawk/sed - read lines from file1, comment out or delete matching lines in file2 rascal84 Linux - General 1 05-24-2006 10:19 AM
Help deleteing lines using Sed nazs Programming 5 03-07-2006 01:38 AM


All times are GMT -5. The time now is 07:30 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
RSS2  LQ Podcast
RSS2  LQ Radio
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration