The files with the extension bash and sh












4















I made some researches about the files with bash and sh extensions. Most of the people and resources say that if a file has bash extension, then it contains bash scripts. Likewise, the file with sh extensions contains sh scripts.



However, I cannot find the differences between bash and sh scripting. There are some courses and articles which aim to teach the people to write scripts on shell, and all of them has the title shell scripting.



In this point, which one does shell scripting correspond to ?



Bash Scripting or Sh scripting.



What I try to understand is what is the difference between bash and sh scripting.










share|improve this question























  • Related: unix.stackexchange.com/questions/9997/…

    – Christopher
    18 hours ago











  • Related: unix.stackexchange.com/questions/48786/…

    – Christopher
    18 hours ago













  • Related: unix.stackexchange.com/questions/145522/…

    – Christopher
    18 hours ago
















4















I made some researches about the files with bash and sh extensions. Most of the people and resources say that if a file has bash extension, then it contains bash scripts. Likewise, the file with sh extensions contains sh scripts.



However, I cannot find the differences between bash and sh scripting. There are some courses and articles which aim to teach the people to write scripts on shell, and all of them has the title shell scripting.



In this point, which one does shell scripting correspond to ?



Bash Scripting or Sh scripting.



What I try to understand is what is the difference between bash and sh scripting.










share|improve this question























  • Related: unix.stackexchange.com/questions/9997/…

    – Christopher
    18 hours ago











  • Related: unix.stackexchange.com/questions/48786/…

    – Christopher
    18 hours ago













  • Related: unix.stackexchange.com/questions/145522/…

    – Christopher
    18 hours ago














4












4








4








I made some researches about the files with bash and sh extensions. Most of the people and resources say that if a file has bash extension, then it contains bash scripts. Likewise, the file with sh extensions contains sh scripts.



However, I cannot find the differences between bash and sh scripting. There are some courses and articles which aim to teach the people to write scripts on shell, and all of them has the title shell scripting.



In this point, which one does shell scripting correspond to ?



Bash Scripting or Sh scripting.



What I try to understand is what is the difference between bash and sh scripting.










share|improve this question














I made some researches about the files with bash and sh extensions. Most of the people and resources say that if a file has bash extension, then it contains bash scripts. Likewise, the file with sh extensions contains sh scripts.



However, I cannot find the differences between bash and sh scripting. There are some courses and articles which aim to teach the people to write scripts on shell, and all of them has the title shell scripting.



In this point, which one does shell scripting correspond to ?



Bash Scripting or Sh scripting.



What I try to understand is what is the difference between bash and sh scripting.







bash shell-script shell






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 18 hours ago









GoktugGoktug

1767




1767













  • Related: unix.stackexchange.com/questions/9997/…

    – Christopher
    18 hours ago











  • Related: unix.stackexchange.com/questions/48786/…

    – Christopher
    18 hours ago













  • Related: unix.stackexchange.com/questions/145522/…

    – Christopher
    18 hours ago



















  • Related: unix.stackexchange.com/questions/9997/…

    – Christopher
    18 hours ago











  • Related: unix.stackexchange.com/questions/48786/…

    – Christopher
    18 hours ago













  • Related: unix.stackexchange.com/questions/145522/…

    – Christopher
    18 hours ago

















Related: unix.stackexchange.com/questions/9997/…

– Christopher
18 hours ago





Related: unix.stackexchange.com/questions/9997/…

– Christopher
18 hours ago













Related: unix.stackexchange.com/questions/48786/…

– Christopher
18 hours ago







Related: unix.stackexchange.com/questions/48786/…

– Christopher
18 hours ago















Related: unix.stackexchange.com/questions/145522/…

– Christopher
18 hours ago





Related: unix.stackexchange.com/questions/145522/…

– Christopher
18 hours ago










2 Answers
2






active

oldest

votes


















16














File names in POSIXland don't have "extensions". A . in a filename is no different from any other character and has no specific meaning other than those that might be attributed to them by meatbags such as ourselves.



One could hope that any file with a name ending in .bash would be a script meant to be executed via the bash shell, but there is no guarantee of this.



Indeed, it's quite common to give all shell scripts a suffix of .sh no matter which interpreter is intended for their use, as the shebang line should properly specify which shell should be used to execute such a file.



sh and bash are two different, but related, shells; two amongst many others such as ksh, csh, zsh, fish, ash, dash, and yet more others.



Each shell has its own syntax, capabilities, mannerisms, and foibles; some shells are largely compatible with each other (generally any script written for sh can also be run in bash or many other shells), but some are not.






share|improve this answer

































    2














    The only significant issue I find day-to-day between bash and sh is the comparison operator. In bash the double-equals operator == can be used for string comparison:



    if [ "$var" == "foo" ]; then  # bash


    But in sh this is a syntax error, as it expects single-equals.



    if [ "$var" = "foo" ]; then   # sh


    I am not saying this is the only difference, but this is a commonly found issue.






    share|improve this answer
























    • Search for bashisms to find out more differences.

      – wurtel
      2 hours ago











    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
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f495147%2fthe-files-with-the-extension-bash-and-sh%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    16














    File names in POSIXland don't have "extensions". A . in a filename is no different from any other character and has no specific meaning other than those that might be attributed to them by meatbags such as ourselves.



    One could hope that any file with a name ending in .bash would be a script meant to be executed via the bash shell, but there is no guarantee of this.



    Indeed, it's quite common to give all shell scripts a suffix of .sh no matter which interpreter is intended for their use, as the shebang line should properly specify which shell should be used to execute such a file.



    sh and bash are two different, but related, shells; two amongst many others such as ksh, csh, zsh, fish, ash, dash, and yet more others.



    Each shell has its own syntax, capabilities, mannerisms, and foibles; some shells are largely compatible with each other (generally any script written for sh can also be run in bash or many other shells), but some are not.






    share|improve this answer






























      16














      File names in POSIXland don't have "extensions". A . in a filename is no different from any other character and has no specific meaning other than those that might be attributed to them by meatbags such as ourselves.



      One could hope that any file with a name ending in .bash would be a script meant to be executed via the bash shell, but there is no guarantee of this.



      Indeed, it's quite common to give all shell scripts a suffix of .sh no matter which interpreter is intended for their use, as the shebang line should properly specify which shell should be used to execute such a file.



      sh and bash are two different, but related, shells; two amongst many others such as ksh, csh, zsh, fish, ash, dash, and yet more others.



      Each shell has its own syntax, capabilities, mannerisms, and foibles; some shells are largely compatible with each other (generally any script written for sh can also be run in bash or many other shells), but some are not.






      share|improve this answer




























        16












        16








        16







        File names in POSIXland don't have "extensions". A . in a filename is no different from any other character and has no specific meaning other than those that might be attributed to them by meatbags such as ourselves.



        One could hope that any file with a name ending in .bash would be a script meant to be executed via the bash shell, but there is no guarantee of this.



        Indeed, it's quite common to give all shell scripts a suffix of .sh no matter which interpreter is intended for their use, as the shebang line should properly specify which shell should be used to execute such a file.



        sh and bash are two different, but related, shells; two amongst many others such as ksh, csh, zsh, fish, ash, dash, and yet more others.



        Each shell has its own syntax, capabilities, mannerisms, and foibles; some shells are largely compatible with each other (generally any script written for sh can also be run in bash or many other shells), but some are not.






        share|improve this answer















        File names in POSIXland don't have "extensions". A . in a filename is no different from any other character and has no specific meaning other than those that might be attributed to them by meatbags such as ourselves.



        One could hope that any file with a name ending in .bash would be a script meant to be executed via the bash shell, but there is no guarantee of this.



        Indeed, it's quite common to give all shell scripts a suffix of .sh no matter which interpreter is intended for their use, as the shebang line should properly specify which shell should be used to execute such a file.



        sh and bash are two different, but related, shells; two amongst many others such as ksh, csh, zsh, fish, ash, dash, and yet more others.



        Each shell has its own syntax, capabilities, mannerisms, and foibles; some shells are largely compatible with each other (generally any script written for sh can also be run in bash or many other shells), but some are not.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited 18 hours ago

























        answered 18 hours ago









        DopeGhotiDopeGhoti

        44.2k55683




        44.2k55683

























            2














            The only significant issue I find day-to-day between bash and sh is the comparison operator. In bash the double-equals operator == can be used for string comparison:



            if [ "$var" == "foo" ]; then  # bash


            But in sh this is a syntax error, as it expects single-equals.



            if [ "$var" = "foo" ]; then   # sh


            I am not saying this is the only difference, but this is a commonly found issue.






            share|improve this answer
























            • Search for bashisms to find out more differences.

              – wurtel
              2 hours ago
















            2














            The only significant issue I find day-to-day between bash and sh is the comparison operator. In bash the double-equals operator == can be used for string comparison:



            if [ "$var" == "foo" ]; then  # bash


            But in sh this is a syntax error, as it expects single-equals.



            if [ "$var" = "foo" ]; then   # sh


            I am not saying this is the only difference, but this is a commonly found issue.






            share|improve this answer
























            • Search for bashisms to find out more differences.

              – wurtel
              2 hours ago














            2












            2








            2







            The only significant issue I find day-to-day between bash and sh is the comparison operator. In bash the double-equals operator == can be used for string comparison:



            if [ "$var" == "foo" ]; then  # bash


            But in sh this is a syntax error, as it expects single-equals.



            if [ "$var" = "foo" ]; then   # sh


            I am not saying this is the only difference, but this is a commonly found issue.






            share|improve this answer













            The only significant issue I find day-to-day between bash and sh is the comparison operator. In bash the double-equals operator == can be used for string comparison:



            if [ "$var" == "foo" ]; then  # bash


            But in sh this is a syntax error, as it expects single-equals.



            if [ "$var" = "foo" ]; then   # sh


            I am not saying this is the only difference, but this is a commonly found issue.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered 10 hours ago









            KingsleyKingsley

            1212




            1212













            • Search for bashisms to find out more differences.

              – wurtel
              2 hours ago



















            • Search for bashisms to find out more differences.

              – wurtel
              2 hours ago

















            Search for bashisms to find out more differences.

            – wurtel
            2 hours ago





            Search for bashisms to find out more differences.

            – wurtel
            2 hours ago


















            draft saved

            draft discarded




















































            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%2f495147%2fthe-files-with-the-extension-bash-and-sh%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 label and detect the document text images

            Tabula Rosettana

            Aureus (color)