Skip to main content

Linux :

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

Mac os x :

sed -i '.bak' '1s/^/task goes here\'$'\n/g' todo.txt

or

echo -e "task goes here\n$(cat todo.txt)" > todo.txt

or

echo 'task goes here' | cat - todo.txt > temp && mv temp todo.txt
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

Linux :

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

Mac os x :

sed -i '.bak' '1s/^/task goes here\'$'\n/g' todo.txt

or

echo -e "task goes here\n$(cat todo.txt)" > todo.txt

or

echo 'task goes here' | cat - todo.txt > temp && mv temp todo.txt
Source Link
Dennis Williamson
  • 109.2k
  • 19
  • 172
  • 190

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