Share your knowledge at the LQ Wiki.
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, 04: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, 05:11 PM   #2
ReliaFree Maintainer
Registered: Aug 2004
Location: Kalamazoo, Michigan
Distribution: Slackware-current, Cross Linux from Scratch, Gentoo
Posts: 2,812
Blog Entries: 1

Rep: Reputation: 259Reputation: 259Reputation: 259
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 08:30 AM
bash scripting - referring to external arguments into loops linsson Linux - General 2 07-23-2004 01:24 PM
(Bash) Saving READ values in external .conf files spikylee Linux - Newbie 4 10-28-2003 07:46 AM
bash scripting - editing files brian0918 Linux - Newbie 2 07-01-2003 03:27 PM
bash scripting - editing files brian0918 Programming 1 06-30-2003 07:16 PM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 04:31 PM.

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