Did you know LQ has a Linux Hardware Compatibility List?
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 11-02-2006, 03:59 PM   #1
LQ Newbie
Registered: Aug 2006
Posts: 15

Rep: Reputation: 0
Bash Scripting: Editing external files

I'm writing a script which must edit an
external file. I just need to be able to
delete a whole line. I can find the line
by cat'ing the file and then using grep commands,
but how would I then delete this line?
Old 11-02-2006, 04:11 PM   #2
ReliaFree Maintainer
Registered: Aug 2004
Location: Kalamazoo, Michigan
Distribution: Slackware-current, Cross Linux from Scratch, Gentoo
Posts: 2,779
Blog Entries: 1

Rep: Reputation: 243Reputation: 243Reputation: 243
To delete all lines containing a <pattern>
sed -i /<pattern>/d filename
To delete a specific <line>
sed -i <line>d filename
Here's a quick primer.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
moving files that have spaces in variables -bash scripting bhar0761 Programming 10 09-22-2005 07:30 AM
bash scripting - referring to external arguments into loops linsson Linux - General 2 07-23-2004 12:24 PM
(Bash) Saving READ values in external .conf files spikylee Linux - Newbie 4 10-28-2003 06:46 AM
bash scripting - editing files brian0918 Linux - Newbie 2 07-01-2003 02:27 PM
bash scripting - editing files brian0918 Programming 1 06-30-2003 06:16 PM

All times are GMT -5. The time now is 09:11 AM.

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