Top community members
All Wiki Articles Create Wiki Article

Welcome to Dirask IT community! ❤ 💻
We are community that shares solutions with each other.

If you think you have something to add here.

you are welcome with your fresh ideas - List Articles

Bash correct header #!/bin/sh - create simple bin sh shell script with .sh code example

0 contributions
1 points

1. Correct header for a bash script


2. Simple bash sh script with .sh header

Filename eg

Code example:


# print to console
echo 'Hello World'

# will wait until user press Enter


Hello World

3. Steps with explanation how to run this example

  1. Create file (any file works with .sh extension)
  2. Open console in the same directory as our
  3. Enter: $ sh
  4. We see the same result as on below screenshot with result.
  5. If you want to exit script press Enter.

Screenshot with result of script:

4. Sh header explanation - Shebang

This header #!/bin/sh at the beginning of the sh file in Unix is called - 'Shebang'.
The purpose of this header: 

Shebang is used to detect what interpreter will be used to run the script.

Most popular shebang:
#!/bin/sh – Execute the file using the Bourne shell, or a compatible shell
#!/usr/bin/env python – Execute with a Python interpreter

Read more about Shebang on wikipedia - Shebang-(Unix) 

Merged questions

  1. How do I create simple .sh header file in linux?
  2. bin/bash header code example
  3. .sh header code example
  4. #!/bin/sh - simple example of header bash script
  5. How to create correct header of linux shell script?


  1. Bash (Unix shell)
  2. Shebang-(Unix)
  3. Shell script
  4. Unix shell
0 contributions

Checkout latest Findings & News:

Checkout latest questions:

Checkout latest wiki articles:

Hey đź‘‹
Would you like to know what we do?
  • Dirask is IT community, where we share coding knowledge and help each other to solve coding problems.
  • We welcome everyone,
    no matter what the experience,
    no matter how basic the question is,
    this community will help you.
Read more