How to delete DOS Terminator

Time:2019-12-14

DOS Terminator: CRLF carriage return line feed

#Check if the file contains CRLF
1. file dosfile 
Return to CRLF

2. cat -a dosfile 
Back to ^ m

#Delete CRLF
1. vim       
    :set fileformat=unix  # :set ff=unix 
    :w   

    :s/^M//gc  # Linux: Ctrl+V+M Enter, AIX: Ctrl+V Ctrl+^ Enter 
    :w 

2. dos2uninx dosfile     

3. col -bx  dosfile 

4. sed -e ‘s/^M//’ dosfile 

5. tr                  
tr -s “\r\n” “\n” dosfile 
tr -d “\r” dosfile  

6. cat dosfile | perl -pe ‘~s//r//g’ 

Use the copy command of DOS to merge files (how to eliminate the 1A terminator at the end)

Recently, the company’s tenmore feedhandler project has split and stored a large number of rawdata files. Because tenforrawdata is very large, the storage policy is to store one rawdata file every hour. However, when performing data analysis playback, you want to combine them into a large file. At first, I wanted to find a third-party merge tool on the Internet. Later, I thought that the DOS copy command could not merge files? Try it now!
For example, you want to combine a.dat and B.dat into c.dat. Among them, the binary content of a.dat is as follows: “30 78 30 31 30 78 30 32”, the binary content of B.dat is as follows: “30 78 30 33 30 78 30 34”, and a DOS script, merge.bat, is written, the content of which is as follows: “copy a.dat + B.dat c.dat”.
However, the newly generated c.dat file has an additional ending character “1A”. The content of the c.dat file is as follows: “30 78 30 31 30 78 30 78 30 33 30 78 30 34 1A”.
Later, I went online to find out the reason. Because the copy command, by default, treats both the target file and the source file as text files, the newly generated file is provided with the text end character “1A”.
The solution is very simple, that is, when copying, it indicates that it is copying binary files.
The new batch content is as follows:“copy /b a.dat+b.dat c.dat