Created
February 6, 2014 23:35
-
-
Save nad2000/8854762 to your computer and use it in GitHub Desktop.
How do I add text to the beginning of a file in Bash?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo 'task goes here' | cat - todo.txt > temp && mv temp todo.txt | |
# OR | |
cat <(echo "task goes here") todo.txt > todo_new.txt | |
# OR | |
echo -e "task goes here\n$(cat todo.txt)" > todo.txt | |
# OR | |
sed -i '1s/^/task goes here\n/' todo.txt | |
# OR | |
sed -i '1itask goes here' todo.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment