Shell script bash: ./:/bin/bash^M: Corrupted interpreter: Nothing to that file or directory
Sometimes when writing scripts, you will get errors similar to those listed in the title. Most of this problem is because your script files have been edited under Windows. Under Windows, the end of each line is \n\r, and in Linux, the end of the file is \n. Then when the file you edited under Windows is open and viewed under Linux, there will be an extra character at the end of each line. When using cat -A urfile, you can see that this \r character is displayed as ^M. At this time, you only need to delete this character. You can use the command sed -i 's/\r$//' urfile . Sometimes when writing scripts, you will get errors similar to those listed in the title. Most of this problem is because your script files have been edited under Windows. Under Windows, the end of each line is \n\r, and in Linux, the end of the file is \n. Then when the file you edited under Windows is open and viewed under Linux, there will be an extra character at the end of each line. When using cat -A urfile, you can see that this \r character is displayed as ^M. At this time, you only need to delete this character. You can use the command sed -i 's/\r$//' urfile .
Related Articles
Installation steps of Apache server (picture and text tutorial)
Below, the editor will bring you an Apache server installation step (picture tutorial). The editor thinks it is quite good, so I will share it with you now and give you a reference. Let's take a look with the editor2017-05-05linux shell implementation finds the maximum and minimum values in a multidimensional array
This article mainly introduces the implementation of linux shell to find the maximum and minimum values in a multi-dimensional array. Friends who need it can refer to it2016-08-08How to use shell to send tcp package
Today, the editor will share with you an article about using shell to send tcp packages. The editor thinks the content is pretty good. Now I share it with you. It has good reference value. Friends in need will follow the editor to take a look.2019-04-04Shell eval implements the method of obtaining environment variables through variables
This article mainly introduces the method of Shell eval to obtain environment variables through variables. The article introduces the example code in detail, which has certain reference learning value for everyone's learning or work. Friends who need it, please learn with the editor below.2020-12-12Introduction to several ways to use perl to obtain native IP in Linux
There are many scenarios for obtaining native IP, such as when performing distributed processing. So, how to get the native ip in the worker script? This article lists a series of methods, including long and short, each with its advantages and disadvantages, shell, perl, and python2013-02-02Detailed explanation of Linux rm command: How to delete file directories in Linux
This article mainly introduces the detailed explanation of Linux rm commands, Linux deletion file directory, this article introduces you very detailedly, and has certain reference value for your study or work. Friends who need it can refer to it2023-01-01Detailed explanation of the difference between while and for in Shell programming
Loops are often used in shell programming, and the commonly used loops are for and while loops. While loop reads files with lines by default, while for loop reads files with spaces. This article will combine some usage examples of the current network to explain the usage and differences between the two.2016-02-02Bash tips: Assign variables to newlines (judging whether the file ends with newlines)
This article mainly introduces Bash skills: assign variables to newlines to determine whether the file ends with newlines. Friends who need it can refer to it2020-08-08The problem of pidof command not being able to obtain the program's pid problem
This article mainly introduces the solution to the problem of pid that cannot be obtained from the program by pidof command. Friends in need can refer to it for reference. I hope it can be helpful. I wish you more progress and get promoted as soon as possible to get a salary increase.2023-09-09Conditional control and loop statements for shell scripts
This article mainly introduces the relevant information of conditional control and loop statements of Shell scripts. Friends who need it can refer to it.2016-05-05