Sample Header Ad - 728x90

Removing control M characters from a given file and to remove newline character if it is the only character in the entire file

1 vote
1 answer
2750 views
We have a file named as abc.txt and its a empty file. Due to some junk or control M characters, the file size is populated as 5 byte file. In order to have clean file we are using dos2unix command to remove the unknown character's. After using dso2unix command We can see the file size as 1 byte as it only contains a new line character .Can i know how to remove newline character if it is the only character in the entire file ? **Work Around :** cat abc.txt cat -v abc.txt M-oM-;M-?^M ll abc.txt -rw-r--r-- 1 ORAPRD ADMIN 5 Jan 25 07:08 abc.txt dos2unix abc.txt dos2unix: converting file abc.txt to Unix format ... ll abc.txt -rw-r--r-- 1 shpprd ADMIN 1 Jan 25 07:09 abc.txt cat -v abc.txt od -c abc.txt 0000000 \n 0000001 Does any one have solution for this? Thank you.
Asked by Rak kundra (548 rep)
Jan 25, 2019, 12:29 PM
Last activity: Jan 27, 2019, 06:37 PM