Using Sed to Add a Line To The Top of a File
This is a simple method to add a line to the top of a file using sed. I've found it a simple alternative to editing a file for a trivial task.
- Use sed to add a line to the top of a file:
sed -i '1s/^/some\ basic\ text\n/' ~/example.txt