i’m pretty new to the shell scripting world and not sure, if i should give my scripts a .sh or .bash extension.

not sure what the pros and cons are.

  • Kevin@programming.dev
    link
    fedilink
    English
    arrow-up
    7
    ·
    1 year ago

    Usually I have most of my (admittedly very few) scripts be .sh with #!/bin/bash. I do have a few that don’t have an extension however, and those are in my $PATH intended to be used as shell commands

    • HerbErtlinger@vlemmy.net
      link
      fedilink
      English
      arrow-up
      3
      ·
      1 year ago

      This is how I do it as well. Shell scripts that I include in a project are named with a .sh extension so other users can identify them easily. Scripts that I want to run as commands often are in my $HOME/bin/ and don’t have an extension. Sometimes those are convenience symlinks with easier names, so ~/bin/example might be a link to ~/repos/example-project/example-script-with-long-name.sh.