CRLF conversion for windows and linux Files
1. CRLFCRLF -- Carriage-Return Line-Feed press enter to wrap the Line.
CR: Press enter, ASCII 13, \ r, LF: line feed, LF, ASCII 10, \ n. Use \ r \ n for windows and \ n for linux. Windows disconnection character ^ M $. in linux, only $ can be executed if the shell file in linux contains ^ M characters. Remove \ r. 2. The dos2unix and unix2dosdos2unix and unix2dos commands are used to convert CRLF.
dos2unix -kn file newfile
-K keep the source file mtime-n keep the old file, and the conversion result is output to the new file. 3. Use the example test file created in windows.
# Test is A windows File $ cat-A testbaidu ^ M $ google ^ M $ # convert to linux $ dos2unix-k-n test. linuxdos2unix: converting file test to file test. linux in UNIX format... # The file size is inconsistent because the viewing time is the same. $ ll-rw-r -- 1 work 15 Aug 9 test-rw ------- 1 work 13 Aug 9 test. linux # cat-A view $ cat-A test. linux baidu $ google $ # convert unix to windows $ unix2dos test. linux unix2dos: converting file test. linux to DOS format... # view the size and time $ ll-rw-r -- 1 work 15 Aug 9 test-rw ------- 1 work 15 Aug 9 test. linux
Address: http://blog.csdn.net/yonggang7/article/details/38459143