Skip to main content
3 of 3
replaced http://unix.stackexchange.com/ with https://unix.stackexchange.com/

Overwriting an input file

Solutions that I have come across for replacing the contents of an input file with converted output involve using a temp file or the sponge utility.

Stephane Chazelas's answer here indicates another way involving opening the file in read-write mode as below.

tr ' ' '\t' < file 1<> file

How does this actually work without corrupting the file in question?

iruvar
  • 17k
  • 8
  • 51
  • 81