This article is a mirror article of machine translation, please click here to jump to the original article.

View: 11259|Reply: 1

[linux] .sh file execution error: -bash: xxx: /bin/sh^M: bad interpreter: No such file or direc...

[Copy link]
Posted on 3/19/2017 10:05:13 PM | | | |
.sh file execution error: -bash: xxx: /bin/sh^M: bad interpreter: No such file or directory Workaround



LinuxLinux is a free-to-use and freely distributed Unix-like operating system, which is a multi-user, multi-tasking, multi-threaded and multi-CPU operating system based on POSIX and UNIX. It runs major UNIX tools, applications, and network protocols.

This article explains to you .sh file execution error: -bash: xxx: /bin/sh^M: bad interpreter: No such file or directory Solution, interested students refer to it.
Error description:
#./bin/sh  
echo "test sh file"
An error is reported when executing ./test.sh file in Ubuntu terminal, prompting: -bash: xxx: /bin/sh^M: bad interpreter: No such file or directory
At that time, I thought about it, impossible, how could there be no such path?
Open the file using the vim tool
:set ff


I found that the current document is in doc format
fileformat = doc
Cause analysis:
It is estimated that it may be because of the dual system, the reason for editing and saving under Windows, after testing again, it was found that this is indeed the case.
Workaround:
1. In the vim tool environment
:set ff = unix  


2. Download a doc2unix tool to solve this problem.
3. Use the editing of the notepadd++ emeditor class to transcode, as shown in the figure below







Previous:VisualSVN Server Configuration and Usage (Project Deployment on SVN)
Next:A Linux shell scrip{filter}t that modifies the configuration file
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com