Skip to content

Instantly share code, notes, and snippets.

@fernandojsg
Created May 21, 2015 06:50
Show Gist options
  • Save fernandojsg/6e09e68f6d2205237316 to your computer and use it in GitHub Desktop.
Save fernandojsg/6e09e68f6d2205237316 to your computer and use it in GitHub Desktop.
Convert DOS Newlines CR-LF file to Unix/Linux format

#Using dos2unix Replacing the original file:

dos2unix filename

Creating a .bak copy of the original:

dos2unix -b filename

#Using tr command tr -d '\r' < input.file > output.file

#Using Perl One Liner perl -pi -e 's/\r\n/\n/g' input.file

#Using bash shell: sed 's/$'"/`echo \\\r`/" input.txt > output.txt

#Using sed command sed 's/^M$//' input.txt > output.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment