Tag Archives: sed

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

Use the $a syntax and sed: sed -i ‘$a some text’ filenamesed -i ‘$a some text’ filename -i parameter means in place. To test without changing the original file, remove the -i option. The results will be print on the … Continue reading

Posted in Linux | Tagged | 2 Comments

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

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: ls *.txt | … Continue reading

Posted in Linux | Tagged | Leave a comment

SED: replace a pattern in all files in one command

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 changes. … Continue reading

Posted in Linux | Tagged | Leave a comment

Combine AWK and SED to create symbolic links

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 line. … Continue reading

Posted in Linux | Tagged , | 1 Comment

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

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: ls *.rst … Continue reading

Posted in Linux | Tagged | Leave a comment