Difference between revisions of "Remove DOS line endings from Text files (CR/LF)"

From Tech-Wiki
Jump to: navigation, search
(Created page with "Category:Linux dos2unix is a commandline utility that will do this, or :%s/^M//g will if you use Ctrl-v Ctrl-m to input the ^M, or you can :set ff=unix and vim will do it...")
 
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
[[Category:Linux]]
 
[[Category:Linux]]
 +
dos2unix is a command line utility that will do this.
  
dos2unix is a commandline utility that will do this, or :%s/^M//g will if you use Ctrl-v Ctrl-m to input the ^M, or you can :set ff=unix and vim will do it for you.
+
Or in vim you can use:
 
+
:%s/\r/\r/g  or
Or in vim you can use: :%s/\r/\r/g  or:
+
:%s/^M//g use Ctrl-v Ctrl-m to input the ^M
 +
:set fileformat=unix
  
 
  sed 's/^M$//' windows.txt > unix.txt
 
  sed 's/^M$//' windows.txt > unix.txt
 
  sed 's/\r$//' windows.txt > unix.txt
 
  sed 's/\r$//' windows.txt > unix.txt
 
  tr -d '\r' < windows.txt > unix.txt
 
  tr -d '\r' < windows.txt > unix.txt

Latest revision as of 21:19, 23 June 2019

dos2unix is a command line utility that will do this.

Or in vim you can use:

:%s/\r/\r/g  or
:%s/^M//g  use Ctrl-v Ctrl-m to input the ^M
:set fileformat=unix
sed 's/^M$//' windows.txt > unix.txt
sed 's/\r$//' windows.txt > unix.txt
tr -d '\r' < windows.txt > unix.txt