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

Correct me if I'm wrong:

  • "sh" script != "bash" script
  • Linux script are written in Bash
  • Bash script usually #!/bin/sh
  • In GNU/Linux, /bin/sh is Bash
  • In FreeBSD, /bin/sh is not bash, it's the true sh

So if I want to use a Linux script in FreeBSD, and I run ./script.sh in the shell, it will run the Bash script in "sh" and not Bash, since /bin/sh in FreeBSD is not Bash.

Is there a way I could run those Bash scripts, without modifying it? So no modification to the #!/bin/sh statement in the script file to point somewhere else?

I would like to run Bash script trough Zsh, if possible. Don't want to install Bash, and since Zsh can run Bash scripts...

share|improve this question
up vote 3 down vote accepted

You can call your favorite shell with the script as a parameter.

bash ./script.sh
share|improve this answer
"Don't want to install Bash" - OP doesn't want to run bash. – Mat Aug 5 '12 at 13:01
well it could be zsh too, thats why i wrote "favorite shell" – arved Aug 5 '12 at 13:48
But, without calling the program bash (or zsh) with a script as an argument? In the last resort, I could do that, but the ./filetoexecute.sh is faster to write, than bash filetoexecute.sh or zsh filetoexecute.sh. Also, Strange the way you say it... bash ./something... Never saw someone using the ./ as an argument – user1115057 Aug 5 '12 at 15:36
Another option would be to modify your system to install zsh as /bin/sh. – arved Aug 5 '12 at 16:19

I run FBSD myself. There was a post about this problem elsewhere too. I found that starting the script with the following greatly improves cross OS compatibility:

#!/usr/bin/env bash

share|improve this answer
While that is correct and helpful when writing a new script it does not really answer the question here. The OP asked explicitly for a solution where already existing files do not need to be edited before they can be used. – Adaephon Jan 30 '15 at 10:53

If you really want to run Linux based written script using /bin/bash in FreeBSD without modifying them, then you can simply copy /usr/local/bin/bash to /bin/bash at Free BSD and it will work.

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.