Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

4
  • I would go for (echo 'ble'; cat todo.txt) :-) Commented Dec 4, 2018 at 9:37
  • I would use tee instead of sponge which come by default on most distro echo "task goes here" | cat - todo.txt | tee todo.txt
    – Angel115
    Commented Apr 28, 2020 at 17:12
  • 1
    The tee example is not correct askubuntu.com/a/752451
    – Zombo
    Commented May 1, 2020 at 14:51
  • @stevenpenny Good point. Now I remember why I didn't suggest it originally. I came back to this answer not noticing that the output file name was the same as the input, which is why you need sponge to buffer it all before writing it back out.
    – slhck
    Commented May 2, 2020 at 12:07