28

When using echo "foo">> bar.txt more than once it appends to the end of a file. How to overwrite bar.txt each time?

J.Olufsen
  • 3,852

1 Answers1

50

> is for redirecting to a file (overwriting it), while >> is for appending.

To overwrite bar.txt, use this:

echo "foo" > bar.txt
Dennis
  • 50,701