from Windows to the Linux of the Shell scripting Coding and formatting issues
Shell script encoding and formatting issues from Windows to Linux
1, abnormal problem: set Ff=unix
- Startup script in the start times error, such as the execution of SH start.sh, when the command is not found and so on,
Because the script that we write or modify in Windows is DOS code, and the normal execution in Linux system is UNIX encoding, when writing shell script, after the development of windows, upload to the server, may have the file format is incorrect, by: set FF UNIX can set the DOS format to a file format under UNIX,
Workaround: Enter in non-edit mode in the configuration file:
FF is a shorthand for fileencoding, and the following FF can also be written as fileencoding
: Set Ff=unix
: Wq
2. Query code: Set fileencoding
: Set fileencoding
3, Conversion code: Set Fenc=utf-8
Converts the encoding of the current text to the specified encoding, where the "encoding" is common for GBK utf-8 big5cp936
: Set fenc= encoding #比如下面的, note to: W Save it,
: Set Fenc=utf-8
: W
4. Display specified encoding: set Enc=utf-8
Displays text with the specified encoding, but not to a file.
The "code" here is common for GBK utf-8 Big5 cp936
: Set enc= encoding #比如:
: Set Enc=utf-8
5. Viewing mode: Set FF
View the pattern type of the current text, typically Dos,unix
: Set FF
6. Setup mode: Set Ff=unix
: Set Ff=unix
Or
: Set Ff=dos
: W
:%s/^m//g Here is if the text inside has ^m end words with this command.
Shell script encoding and formatting issues from Windows to Linux