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 | xargs sed -e '1i author: your name' |
Where ‘1i’ means insert on the first line. Note also that you must replace sed -e by sed -i -e to replace the file content, otherwise it is like a dry run.
Please follow and like us: