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;








2















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.










share|improve this question









New contributor




Malkavian is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.















  • 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

















2















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.










share|improve this question









New contributor




Malkavian is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.















  • 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













2












2








2








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.










share|improve this question









New contributor




Malkavian is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












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






share|improve this question









New contributor




Malkavian is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Malkavian is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 11 hours ago









Rui F Ribeiro

42.1k1484142




42.1k1484142






New contributor




Malkavian is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 11 hours ago









MalkavianMalkavian

142




142




New contributor




Malkavian is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Malkavian is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Malkavian is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







  • 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












  • 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







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










1 Answer
1






active

oldest

votes


















8














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







share|improve this answer

























    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.









    draft saved

    draft discarded


















    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









    8














    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







    share|improve this answer





























      8














      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







      share|improve this answer



























        8












        8








        8







        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







        share|improve this answer















        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








        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited 11 hours ago

























        answered 11 hours ago









        msp9011msp9011

        4,70844167




        4,70844167




















            Malkavian is a new contributor. Be nice, and check out our Code of Conduct.









            draft saved

            draft discarded


















            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.




            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            How to create a command for the “strange m” symbol in latex? Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)How do you make your own symbol when Detexify fails?Writing bold small caps with mathpazo packageplus-minus symbol with parenthesis around the minus signGreek character in Beamer document titleHow to create dashed right arrow over symbol?Currency symbol: Turkish LiraDouble prec as a single symbol?Plus Sign Too Big; How to Call adfbullet?Is there a TeX macro for three-legged pi?How do I get my integral-like symbol to align like the integral?How to selectively substitute a letter with another symbol representing the same letterHow do I generate a less than symbol and vertical bar that are the same height?

            Българска екзархия Съдържание История | Български екзарси | Вижте също | Външни препратки | Литература | Бележки | НавигацияУстав за управлението на българската екзархия. Цариград, 1870Слово на Ловешкия митрополит Иларион при откриването на Българския народен събор в Цариград на 23. II. 1870 г.Българската правда и гръцката кривда. От С. М. (= Софийски Мелетий). Цариград, 1872Предстоятели на Българската екзархияПодмененият ВеликденИнформационна агенция „Фокус“Димитър Ризов. Българите в техните исторически, етнографически и политически граници (Атлас съдържащ 40 карти). Berlin, Königliche Hoflithographie, Hof-Buch- und -Steindruckerei Wilhelm Greve, 1917Report of the International Commission to Inquire into the Causes and Conduct of the Balkan Wars

            Чепеларе Съдържание География | История | Население | Спортни и природни забележителности | Културни и исторически обекти | Религии | Обществени институции | Известни личности | Редовни събития | Галерия | Източници | Литература | Външни препратки | Навигация41°43′23.99″ с. ш. 24°41′09.99″ и. д. / 41.723333° с. ш. 24.686111° и. д.*ЧепелареЧепеларски Linux fest 2002Начало на Зимен сезон 2005/06Национални хайдушки празници „Капитан Петко Войвода“Град ЧепелареЧепеларе – народният ски курортbgrod.orgwww.terranatura.hit.bgСправка за населението на гр. Исперих, общ. Исперих, обл. РазградМузей на родопския карстМузей на спорта и скитеЧепеларебългарскибългарскианглийскитукИстория на градаСки писти в ЧепелареВремето в ЧепелареРадио и телевизия в ЧепелареЧепеларе мами с родопски чар и добри пистиЕвтин туризъм и снежни атракции в ЧепелареМестоположениеИнформация и снимки от музея на родопския карст3D панорами от ЧепелареЧепелареррр