For POSIX (ie. not just Linux):
#!/bin/sh.
For GNU bash:
#!/bin/bash
or
#!/usr/bin/env bash
Note: Use the latter if the following scenario applies:
#!/usr/bin/env
searches PATH for bash, and bash is not always in /bin, particularly on non-Linux systems. For example, on my OpenBSD system, it's in/usr/local/bin
, since it was installed as an optional package.If you are absolutely sure bash is in
/bin
and will always be, there's no harm in putting it directly in your shebang—but I'd recommend against it because scripts and programs all have lives beyond what we initially believe they will have.
For python. Source: https://stackoverflow.com/a/19305076
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
For python 2 and 3; rare case where compatibility with both versions is required.
#!/usr/bin/env python
# -*- coding: utf-8 -*-