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.

Required fields*

4
  • 2
    No it won't. It will update the timestamp on the file, but will leave the contents unaltered. It will create an emtpy file if there was not one there already though Commented Feb 1, 2016 at 15:34
  • Eric is correct. Touch will not clear the contents of the file. My bad. Commented Feb 1, 2016 at 15:38
  • Still not quite, that would try to execute filename and redirect it's stdin to be from /dev/null. You can look at the comment from Marco to see an example of how to use redirection to do this (it works by running an "empty" command : and redirecting the output of that into the file) Commented Feb 1, 2016 at 15:40
  • Refer to linkDifference between cat and '>' to zero out a file Answers from Patrick and Stéphane Chazelas Commented Feb 1, 2016 at 15:57