7

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
Majid Azimi
  • 3,098

1 Answers1

11

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.

Karlson
  • 5,875