tr command not able to direct the Output?
linux, sed, tr
Solution
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
Problem
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.