LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
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.

Notices

Reply
 
Search this Thread
Old 11-02-2006, 03:59 PM   #1
trek413
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
weibullguy
ReliaFree Maintainer
 
Registered: Aug 2004
Location: Kalamazoo, Michigan
Distribution: Slackware-current, Cross Linux from Scratch, Gentoo
Posts: 2,745
Blog Entries: 1

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


Reply


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 04:10 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
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration