Questions tagged [shebang]

In computing, a shebang is the character sequence consisting of the characters number sign and exclamation mark (that is, "#!") at the beginning of a script.

Filter by
Sorted by
Tagged with
25 votes
3 answers
8k views

What type of path in shebang is more preferable?

In scripts, first line should specify the path to interpreter. But on different servers Linux, Unix, or BSD this path could be different. What is more preferable? #!/usr/bin/env bash or #!/bin/...
Roman Ivanov's user avatar
416 votes
4 answers
877k views

What is the difference between #!/bin/sh and #!/bin/bash?

if I write, #!/bin/bash echo "foo" or #!/bin/sh echo "foo" both yields same. I have seen some scripts starting with #!/bin/sh or #!/bin/bash. Is there any difference between them?
Rahul Virpara's user avatar
3 votes
3 answers
794 views

What is this line at the top of many files?

I have seen many files which have this line as the first line in them. What exactly is this? #!/usr/bin/env python What does it mean? Why is it necessary?
hellodear's user avatar
  • 4,683
47 votes
3 answers
8k views

Is there a command for running a script according to its shebang line?

If I want to execute a bash script which doesn't have its execution permission set, I can do: bash script.sh What should I use instead of bash if the script isn't executable and I don't know the ...
Aivar's user avatar
  • 635
-4 votes
1 answer
609 views

What is "#!' in a script file? [duplicate]

$cat shebang.sed #! /bin/sed -f s/red/xxx/ s/BLUE/1234/ $./shebang.sed rgb lower (#1): "xxx green blue" UPPER (#2): "RED GREEN 1234" $sed -f shebang.sed rgb lower (#1): "xxx green blue" UPPER (#2): ...
Smile's user avatar
  • 1,099