sh script name -sh: /bin/sh^M: bad interpreter: No such file or directory Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) 2019 Community Moderator Election Results Why I closed the “Why is Kali so hard” questionWhat is `^M` and how do I get rid of it?#!/bin/bash - no such file or directoryshebang line not working with cr-lfExecute file in its native directory with shell scriptmv: cannot stat No such file or directory in shell scriptWeird “No such file” error with “xargs” and “file”Pressing tab after sourcing script file prints script related outputFile exists but mv errors out with: “mv: cannot stat ‘file.tar.gz’: No such file or directory”Running repetitive task through Bash scriptScript not able to generate files for backup fileshell find -delete “directory not empty”Running remote command with ssh getting “bash: /dev/fd/63: No such file or directory”Cannot exec /bin/false: no such file or directory
Bete Noir -- no dairy
Why am I getting the error "non-boolean type specified in a context where a condition is expected" for this request?
Can an alien society believe that their star system is the universe?
If a contract sometimes uses the wrong name, is it still valid?
How to call a function with default parameter through a pointer to function that is the return of another function?
At the end of Thor: Ragnarok why don't the Asgardians turn and head for the Bifrost as per their original plan?
Using audio cues to encourage good posture
Is there a (better) way to access $wpdb results?
Use BFD on a Virtual-Template Interface
How to tell that you are a giant?
Is it true that "carbohydrates are of no use for the basal metabolic need"?
What's the meaning of 間時肆拾貳 at a car parking sign
Why did the rest of the Eastern Bloc not invade Yugoslavia?
Why do we bend a book to keep it straight?
How does the particle を relate to the verb 行く in the structure「A を + B に行く」?
Generate an RGB colour grid
English words in a non-english sci-fi novel
What is the role of the transistor and diode in a soft start circuit?
What LEGO pieces have "real-world" functionality?
Can I cast Passwall to drop an enemy into a 20-foot pit?
How to bypass password on Windows XP account?
What exactly is a "Meth" in Altered Carbon?
Storing hydrofluoric acid before the invention of plastics
Should I use a zero-interest credit card for a large one-time purchase?
sh script name -sh: /bin/sh^M: bad interpreter: No such file or directory
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
2019 Community Moderator Election Results
Why I closed the “Why is Kali so hard” questionWhat is `^M` and how do I get rid of it?#!/bin/bash - no such file or directoryshebang line not working with cr-lfExecute file in its native directory with shell scriptmv: cannot stat No such file or directory in shell scriptWeird “No such file” error with “xargs” and “file”Pressing tab after sourcing script file prints script related outputFile exists but mv errors out with: “mv: cannot stat ‘file.tar.gz’: No such file or directory”Running repetitive task through Bash scriptScript not able to generate files for backup fileshell find -delete “directory not empty”Running remote command with ssh getting “bash: /dev/fd/63: No such file or directory”Cannot exec /bin/false: no such file or directory
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I have the following prompts
[/share/registrazioni/Script] # cat delete_7gg.sh
#!/bin/sh
find /share/registrazioni/ -type f -mtime +7 -delete
[/share/registrazioni/Script] # which sh
/bin/sh
[/share/registrazioni/Script] # chmod +x delete_7gg.sh
[/share/registrazioni/Script] # ./delete_7gg.sh
-sh: ./delete_7gg.sh: /bin/sh^M: bad interpreter: No such file or directory
why do I get /bin/sh^M: bad interpreter: No such file or directory ?
I made the script with vi.
shell
New contributor
|
show 2 more comments
I have the following prompts
[/share/registrazioni/Script] # cat delete_7gg.sh
#!/bin/sh
find /share/registrazioni/ -type f -mtime +7 -delete
[/share/registrazioni/Script] # which sh
/bin/sh
[/share/registrazioni/Script] # chmod +x delete_7gg.sh
[/share/registrazioni/Script] # ./delete_7gg.sh
-sh: ./delete_7gg.sh: /bin/sh^M: bad interpreter: No such file or directory
why do I get /bin/sh^M: bad interpreter: No such file or directory ?
I made the script with vi.
shell
New contributor
1
Related: shebang line not working with cr-lf
– steeldriver
11 hours ago
3
... since you are usingvi
, you can change between line endings using:set ff=unix
and:set ff=dos
– steeldriver
11 hours ago
there are a lot of questions about that CR if you google for^M
What is^M
and how do I get rid of it?, Unix script appends ^M at end of each line, -bash: ./my_script: /bin/bash^M: bad interpreter: No such file or directory...
– phuclv
8 hours ago
2
Possible duplicate of What is `^M` and how do I get rid of it?
– phuclv
8 hours ago
1
Possible duplicate of shebang line not working with cr-lf
– sourcejedi
5 hours ago
|
show 2 more comments
I have the following prompts
[/share/registrazioni/Script] # cat delete_7gg.sh
#!/bin/sh
find /share/registrazioni/ -type f -mtime +7 -delete
[/share/registrazioni/Script] # which sh
/bin/sh
[/share/registrazioni/Script] # chmod +x delete_7gg.sh
[/share/registrazioni/Script] # ./delete_7gg.sh
-sh: ./delete_7gg.sh: /bin/sh^M: bad interpreter: No such file or directory
why do I get /bin/sh^M: bad interpreter: No such file or directory ?
I made the script with vi.
shell
New contributor
I have the following prompts
[/share/registrazioni/Script] # cat delete_7gg.sh
#!/bin/sh
find /share/registrazioni/ -type f -mtime +7 -delete
[/share/registrazioni/Script] # which sh
/bin/sh
[/share/registrazioni/Script] # chmod +x delete_7gg.sh
[/share/registrazioni/Script] # ./delete_7gg.sh
-sh: ./delete_7gg.sh: /bin/sh^M: bad interpreter: No such file or directory
why do I get /bin/sh^M: bad interpreter: No such file or directory ?
I made the script with vi.
shell
shell
New contributor
New contributor
edited 11 hours ago
Rui F Ribeiro
42.1k1484142
42.1k1484142
New contributor
asked 11 hours ago
MalkavianMalkavian
142
142
New contributor
New contributor
1
Related: shebang line not working with cr-lf
– steeldriver
11 hours ago
3
... since you are usingvi
, you can change between line endings using:set ff=unix
and:set ff=dos
– steeldriver
11 hours ago
there are a lot of questions about that CR if you google for^M
What is^M
and how do I get rid of it?, Unix script appends ^M at end of each line, -bash: ./my_script: /bin/bash^M: bad interpreter: No such file or directory...
– phuclv
8 hours ago
2
Possible duplicate of What is `^M` and how do I get rid of it?
– phuclv
8 hours ago
1
Possible duplicate of shebang line not working with cr-lf
– sourcejedi
5 hours ago
|
show 2 more comments
1
Related: shebang line not working with cr-lf
– steeldriver
11 hours ago
3
... since you are usingvi
, you can change between line endings using:set ff=unix
and:set ff=dos
– steeldriver
11 hours ago
there are a lot of questions about that CR if you google for^M
What is^M
and how do I get rid of it?, Unix script appends ^M at end of each line, -bash: ./my_script: /bin/bash^M: bad interpreter: No such file or directory...
– phuclv
8 hours ago
2
Possible duplicate of What is `^M` and how do I get rid of it?
– phuclv
8 hours ago
1
Possible duplicate of shebang line not working with cr-lf
– sourcejedi
5 hours ago
1
1
Related: shebang line not working with cr-lf
– steeldriver
11 hours ago
Related: shebang line not working with cr-lf
– steeldriver
11 hours ago
3
3
... since you are using
vi
, you can change between line endings using :set ff=unix
and :set ff=dos
– steeldriver
11 hours ago
... since you are using
vi
, you can change between line endings using :set ff=unix
and :set ff=dos
– steeldriver
11 hours ago
there are a lot of questions about that CR if you google for
^M
What is ^M
and how do I get rid of it?, Unix script appends ^M at end of each line, -bash: ./my_script: /bin/bash^M: bad interpreter: No such file or directory...– phuclv
8 hours ago
there are a lot of questions about that CR if you google for
^M
What is ^M
and how do I get rid of it?, Unix script appends ^M at end of each line, -bash: ./my_script: /bin/bash^M: bad interpreter: No such file or directory...– phuclv
8 hours ago
2
2
Possible duplicate of What is `^M` and how do I get rid of it?
– phuclv
8 hours ago
Possible duplicate of What is `^M` and how do I get rid of it?
– phuclv
8 hours ago
1
1
Possible duplicate of shebang line not working with cr-lf
– sourcejedi
5 hours ago
Possible duplicate of shebang line not working with cr-lf
– sourcejedi
5 hours ago
|
show 2 more comments
1 Answer
1
active
oldest
votes
You seem to have Windows-style line endings (CRLF, ^M^J) instead of unix-style line endings (LF, ^J). Try dos2unix
dos2unix delete_7gg.sh
then run as usual
From man:
dos2unix - DOS/MAC to UNIX text file format converter
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Malkavian is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f512760%2fsh-script-name-sh-bin-shm-bad-interpreter-no-such-file-or-directory%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You seem to have Windows-style line endings (CRLF, ^M^J) instead of unix-style line endings (LF, ^J). Try dos2unix
dos2unix delete_7gg.sh
then run as usual
From man:
dos2unix - DOS/MAC to UNIX text file format converter
add a comment |
You seem to have Windows-style line endings (CRLF, ^M^J) instead of unix-style line endings (LF, ^J). Try dos2unix
dos2unix delete_7gg.sh
then run as usual
From man:
dos2unix - DOS/MAC to UNIX text file format converter
add a comment |
You seem to have Windows-style line endings (CRLF, ^M^J) instead of unix-style line endings (LF, ^J). Try dos2unix
dos2unix delete_7gg.sh
then run as usual
From man:
dos2unix - DOS/MAC to UNIX text file format converter
You seem to have Windows-style line endings (CRLF, ^M^J) instead of unix-style line endings (LF, ^J). Try dos2unix
dos2unix delete_7gg.sh
then run as usual
From man:
dos2unix - DOS/MAC to UNIX text file format converter
edited 11 hours ago
answered 11 hours ago
msp9011msp9011
4,70844167
4,70844167
add a comment |
add a comment |
Malkavian is a new contributor. Be nice, and check out our Code of Conduct.
Malkavian is a new contributor. Be nice, and check out our Code of Conduct.
Malkavian is a new contributor. Be nice, and check out our Code of Conduct.
Malkavian is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f512760%2fsh-script-name-sh-bin-shm-bad-interpreter-no-such-file-or-directory%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Related: shebang line not working with cr-lf
– steeldriver
11 hours ago
3
... since you are using
vi
, you can change between line endings using:set ff=unix
and:set ff=dos
– steeldriver
11 hours ago
there are a lot of questions about that CR if you google for
^M
What is^M
and how do I get rid of it?, Unix script appends ^M at end of each line, -bash: ./my_script: /bin/bash^M: bad interpreter: No such file or directory...– phuclv
8 hours ago
2
Possible duplicate of What is `^M` and how do I get rid of it?
– phuclv
8 hours ago
1
Possible duplicate of shebang line not working with cr-lf
– sourcejedi
5 hours ago