I will make a small exception for answering jichao. You can do everything that he just talked about quite easily. Instead of searching for \ n, just find the form feed at the end of the line.
sed -i 's/\r$//' ${FILE_NAME}
To move from unix back to dos, simply find the last character in the line and add the form feed to it. (I will add -r to make this easier with grep regular expressions.)
sed -ri 's/(.)$/\1\r/' ${FILE_NAME}
Theoretically, the file can be changed to mac style by adding code to the last example, which also adds the next line of input to the first line until all lines are processed. However, I will not try to make this example.
Warning: -i modifies the actual file. If you want to back up, add a character string after -i. This will move the existing file to a file with the same name with the characters you added.
John Chesshir May 26 '17 at 20:51 2017-05-26 20:51
source share