Shell script encoding and formatting issues from Windows to Linux

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.