I have got a file file.txt witch has got these entries
NY
LA
SF
I ran the command tr '\n' ',' < file.txt and it successfully deleted all of the newline characters.
I need all of this output in the same file.txt file, so I redirected the output like this
tr '\n' ',' < file.txt > file.txt,
but It does not put anything in the file.txt and the resultant file is empty, Can anyone explain to me why the output of tr is getting lost due to redirection.
because it opens the output file first which deletes what is in the file and then feels nothing into the tr command and back out into the empty file
tr '\n' ',' < file.txt > file2.txt
will work
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With