In linux, the text dos format is converted to the unix format, removing the ^ M symbol. Today, we are working on batch query statistics. Because the raw data is text copied from execl, use shell to analyze this batch of data. After waiting for a long time to get the result, I found that the data after the query export is empty, which is very depressing (there are still many things to do ). First, the shell script returns the SQL statements of all execution records to a single text, and finds that each query record exported is divided into two rows, at the beginning, I was not aware of the danger of ^ M. I tried to adjust the shell script repeatedly, So that I changed the shell script to the heaviest full-record search without any conditions. Www.2cto.com (there may be too many things to do, and the brain was not calm enough to grasp the main cause of the problem). The problem still failed to be solved and crashed. Finally, I took out a record and analyzed it separately. I carefully checked that the SQL records returned by the echo were ^ M, speechless.
(How can I ignore ^ M? I should despise myself. Isn't it always a loss ). Finally, compress sed-I "s/^ M/g" to replace it and re-start it. I lament that my recent status is indeed not good. I always feel very annoyed and need to adjust it. I found another article on the Internet that converts line breaks between UNIX and WINDOWS. I learned to add the following: syntax
Dos2unix [-kn] file [newfile] is converted from DOS to UNIXunix2dos [-kn] file [newfile] from UNIX to DOS, that is, WINDOWS-k: retain the original mtime of the document (the time when the last content of the document is not updated)-n: Retain the original document and enter the converted content into the new document. For example: dos2unix-n old new example: www.2cto.com $ cat-v killws #! /Bin/bash ^ Madmin_dir = "/home/admin" ^ Mfunction check_user {^ M if [['whoam '! = "Admin"]; then ^ M echo "Apache only can start by admin user, exit! "^ M exit ^ M fi ^ M} ^ M $ dos2unix-k killwsdos2unix: converting file killws to UNIX format... $ cat-v killws #! /Bin/bashadmin_dir = "/home/admin" function check_user {if [['whoam '! = "Admin"]; then echo "Apache only can start by admin user, exit! "Exit fi} www.2cto.com also has a conversion method: input set ff = unix in vim file directly. Save and quit! ------ End ------