When we write shell scripts we do this:
#!/bin/bash
But What if bash is in /usr/bin/
? How can we find it in a portable way inside script? I did this, but it gives error:
#!which bash
When we write shell scripts we do this:
#!/bin/bash
But What if bash is in /usr/bin/
? How can we find it in a portable way inside script? I did this, but it gives error:
#!which bash
If bash
is in the different location you can hash bang it as follows:
#!/usr/bin/env bash
Location for env
is pretty standard across the variants.
#!/usr/bin/env python
– ncmathsadist Feb 19 '12 at 19:43python
,perl
and all other scripting languages. – Karlson Feb 19 '12 at 20:02bash
as/bin/bash
(via a symlink if necessary) simply because so many scripts out there have#!/bin/bash
. – Keith Thompson Feb 19 '12 at 21:59#!/bin/bash
doesn't necessarily make them right. – Karlson Feb 20 '12 at 00:57