perl -pe -i.bak 's/\n/\r\n/g' filename.txt or perl -pe -i.bak 's/\n/\n\r/g' filename.txt