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 | xargs sed -e '1i #header' |
Replace sed -e by sed -i -e to replace the file content, otherwise it is like a dry run.
Please follow and like us: