Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I find out whether a script is written in bash or sh?

The first line of the script is not helpful here, since on Linux, bash scripts have this line: #!bin/sh

Actually, there are many distribution where /bin/sh is bash (maybe /bin/sh is a link to /bin/bash in those distributions), and not Bourne Shell. So if I try to run a script that is written in bash in, for example, FreeBSD, the result is not defined, since /bin/sh in FreeBSD is Bourne Shell, and not bash.

Is there are easy way to identify if a script is bash or sh?

Are there some distinctive things in syntax?

share|improve this question
See Bashisms on Greg's Wiki... – jasonwryan Aug 6 '12 at 1:11
up vote 15 down vote accepted

Actually the shebang lines means something as some distributions like Debian don't use bash for /bin/sh but dash.

The simplest solution to determine if a shell script is bash is to use checkbashism - see man checkbashisms for details.

checkbashisms should be packaged by different distributions, for Debian it is in the devscripts package - Fedora in devscripts-minimal (it used to be in rpmdevtools) and OpenSuSe in rpmlint-mini

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.