LinuxQuestions.org
Visit the LQ Articles and Editorials section
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
 
LinkBack Search this Thread
Old 03-04-2006, 06:54 PM   #1
3saul
Member
 
Registered: Aug 2004
Location: Brisbane, Australia
Distribution: Ubuntu/Fedora
Posts: 85

Rep: Reputation: 15
SED - replace text in file on specific line


I have the following sed command

sed -e '56s/allow/disallow/g' restrict.txt

It outputs the correct results to the console...however I want it to write the changes back to the file restrict.txt. I tried:

sed -e '56s/allow/disallow/g' restrict.txt > restrict.txt but I end up with a blank txt file.
 
Old 03-04-2006, 07:01 PM   #2
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 56
Try something like this....

sed '56s/allow/disallow/' -i restrict.txt

Last edited by homey; 03-04-2006 at 07:06 PM.
 
  


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Python: find defined text string in a file, and replace the whole line Dark Carnival Programming 6 05-22-2007 06:02 AM
vb.net writing to a specific line in a text file mrobertson Programming 3 12-30-2005 10:24 PM
Writing to a specific line in a text file mrobertson Programming 6 12-30-2005 04:02 PM
SED - display text on specific line of text file 3saul Linux - Software 3 12-29-2005 04:32 PM
Shell script - how to show a specific line of a text file davi_cabral Linux - Software 3 09-28-2004 01:39 PM


All times are GMT -5. The time now is 08:01 AM.

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