perl -i.bak -pe 's/\r(?!\n)/\n/g; tr/\r//d' test.dat