How to remove the dreaded '^M' character in unix files

While there are lots of ways to go about solving the issue, two methods that I find to my liking are:
1. Using 'tr'
tr -d '^M' < [input filename] > [output filename]
e.g; tr -d '^M' < opx_LOD_GEN_110_003110000.ini > test3.txt
2. Using vi editor.
Simply type in the above in your vi editor to get the desired effect. And note that you have to press 'ctrl' AND 'V' and later 'ctrl' AND 'm'. It's not the same as the '^' and 'M' character.
Both of them worked for me.
Details can be found here:


Popular posts from this blog

HIVE: Both Left and Right Aliases Encountered in Join

Assign select result to variable in Netezza stored procedure

Splitting value in Netezza using array_split