Tag Archives: sed

sed: how to add text at the end of the file

Tweet Use the $a syntax and sed:

-i parameter means in place. A previous post explained how to insert a line anywhere but for completeness here it is again:

Posted in Linux | Tagged | Leave a comment

SED: insert text at the top of a bunch of files

Tweet at a line at the top of a file Imagine, you have a set of files ending in .txt, and you want to add the statement #header at the top of each of them. Then, simply type:

Replace … Continue reading

Posted in Linux | Tagged | Leave a comment

SED: replace a pattern in all files in one command

Tweet I have a bunch of c files and I want to change the first line that appears as //something into /*something Using sed, you can use the command ‘s/old_pattern/new_pattern/g’ where -e stands for edition, and -i to apply the … Continue reading

Posted in Linux | Tagged | Leave a comment

Combine AWK and SED to create symbolic links

Tweet The unix tools AWK and SED are very powerful tools to manipulate files and perform text processing tasks. It’s true that the syntax is not always very intuitive but it can help you in performing task in a single … Continue reading

Posted in Linux | Tagged , | 1 Comment

SED: how to add a line at the top of files

Tweet Imagine, you have a set of ReST files, and you want to add the statement “author: your name” at the top of each of them. First, identify the files you want to edit and pipe them to sed:

Continue reading

Posted in Linux | Tagged | Leave a comment