How do I add text to the beginning of a file in Bash?
echo 'task goes here' | cat - todo.txt > temp && mv temp todo.txt
or
sed -i '1s/^/task goes here\n/' todo.txt
or
sed -i '1itask goes here' todo.txt
echo 'task goes here' | cat - todo.txt > temp && mv temp todo.txt
sed -i '1s/^/task goes here\n/' todo.txt
sed -i '1itask goes here' todo.txt
Comments
Post a Comment