Quickzi: How To Replace a Line in a Text File
Here is a quick tip on how to use sed to replace a line in a text file from the command line, without opening it.
Replace a Line in a File
First, replace the text you want with sed and output it into a temporary file to ensure that it is correct:
# sed -e 's/original-text/new-text/' textFile > newFile
newFile and make sure that the line is correctly replaced:
# more newFile
textFile with the
# mv newFile textFile
Popularity: 3% [?]
Filed under: Linux
Like this post? Subscribe to my RSS feed and get loads more!