What is extension & execution command for following file formats -

Bourne Shell, Korn Shell, Bourne Again Shell, POXIS shell & TENEX/TOPS C Shell.

Like normal bash file can be created with '.sh' extension & can easily be executed by command - 'shell filename.sh'.

  • @ilkkachu I am working on a task to automate file execution. I have to automate these file execution, I searched but couldn't get clarity on what are the extension of these file type and execution command. I hope you can help me.
    – Gaurav
    Nov 15, 2021 at 10:58
  • 3
    A script is executed by the interpreter referred to by the #!-line on line 1 of the script (if the file is executable). The filename is unimportant. You should not need to specify an explicit interpreter on the command line at all. I'm uncertain about the context to the question, so I don't know what is actually sought.
    – Kusalananda
    Nov 15, 2021 at 11:01
  • 3
    Does this answer your question? Use .sh or .bash extension for bash scripts? (there might be better duplicates)
    – Kusalananda
    Nov 15, 2021 at 11:05
  • See this link about the #!-line also known as 'shebang' line.
    – sudodus
    Nov 15, 2021 at 11:06

1 Answer 1


The extension is completely irrelevant. With very few exceptions (such as gzip), extensions are optional and arbitrary on *nix systems. A shell script doesn't need an extension and any extension it may have carries absolutely no meaning. You could call a bash script foo.asldifjh and it would work in exactly the same way as foo.sh.

So, to answer your question, for all the shells you mentioned, the extension is irrelevant and all of them can launch a script with shellName /path/to/script. All of them can also use a shebang line. Here's one for ksh for example:

#! /bin/ksh

If the script file has a shebang line and is set to executable (chmod a+x /path/to/script), you can simply run /path/to/script directly and the script will be interpreted by whatever shell you have in the shebang line. Again, the extension is completely irrelevant.

  • 1
    in particular, not relying on the extension but the #! line makes it easier to change the language the script is written in. E.g. if I write a shell script mytool, I can later decide to rewrite it in Perl without changing the name.
    – ilkkachu
    Nov 15, 2021 at 11:58
  • 1
    It may also be worth noting that the pathname mentioned in the #!-line depends on where the specific interpreter is installed. There are common pathnames for shells like sh and bash etc., but thy are not standard. Finding bash at /bin/bash is not guaranteed (but it may be expected, at least on Linux systems of today).
    – Kusalananda
    Nov 15, 2021 at 12:04

Not the answer you're looking for? Browse other questions tagged .