LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   replacing specific lines in a text document (https://www.linuxquestions.org/questions/linux-general-1/replacing-specific-lines-in-a-text-document-227801/)

stellarmarine1 09-07-2004 01:49 PM

replacing specific lines in a text document
 
Is there a way to write a script that would overwrite specific lines in a text file. For instance I would like to change the 1st and 4th line in a text file. How would I go about doing this while incorporating it into a script?

I hate to keep asking all these script writing questions. But it seems that there are so many tutorials out there that I don't know which one to follow.

Any suggestions? :study:

Tinkster 09-07-2004 02:34 PM

man sed

sed -e 'n c <text>' <file>


Where n is the line-number, c the sed command,
<text> the text you want to be on the n'th line.



Cheers,
Tink


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