(original) A shell script compiled under Windows can no longer work with Linux in a workaround

Source: Internet
Author: User

First, the principle

Windows compiled files and Linux compiled file formats are not the same, resulting in Linux running shell scripts when prompted:/bin/bash^m:bad interpreter: There is no file or directory.

The reason is this:

1. When the Windows compiled files end (carriage return + line wrapping)

2. At the end of Linux compiled files (newline)

This causes the Windows compiled files to be placed on Linux with [Noeol] and [DOS] flag flags.

If you run the cat command to see more visually the file differences generated by two different operating systems, there is one more ^min the shell script file generated by Windows.

Command format: cat-a filenamecat-a windows.shcat-a linux.sh

Ii. Solutions

In the windows generated script into the VIM compilation mode, input ": Set Fileformat=unix #转换成unix格式", enter after Wq save exit.

It is now possible to run shell scripts in Linux using./window.sh or SH window.sh.

Done ~

(original) A shell script compiled under Windows can no longer work with Linux in a workaround

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.