Hello, this is Nanopore.
This is my first time asking a question.
I'm trying to delete a new line from the txt file, but I'm having a hard time because I can't delete the new line even if I run the following command.
cat input.txt | tr-d'\n'>output.txt
There are no errors, and if you add a new line,
I'm not sure because line breaks are deleted only in that part...
I would like people with similar experience and troubleshooting experience to consult with me.
Thank you for your cooperation.
Due to historical circumstances, there are three types of line feed codes: CR, LF, and CR+LF.
\r
is CR
\n
is LF
tr
operates in bytes, so tr-d'\n'
only removes LF.On the other hand, Windows/MacOS/Unix cross-platform tools can accept any of three new line breaks.If you delete only the LF from the CR+LF line feed file originally created in Windows, the tool may treat the single CR as a line feed normally.
# If you use cygwin, you will have to mix Unix-derived LF line breaks and MS-DOS-derived CR+LF line breaks, which can cause a lot of trouble.
Removing both CRs and LFs should do what you want.
© 2024 OneMinuteCode. All rights reserved.