Ubuntu’s shell != bash, and how to fix your scripts

November 15, 2010

I just found out that on Ubuntu, /bin/sh is a symlink to /bin/dash, not to /bin/bash.  Apparently this was changed to make booting up a little bit faster.

In any case, it might mean that many of your scripts won’t work because they are starting with ‘#!/bin/sh’.  Instead, you should have them point directly to /bin/bash.  Here’s a one line script that will update all the scripts in a directory:

find . -type f | xargs sed -i ‘s_#!/bin/sh_!/bin/bash_’

Advertisement

One Response to “Ubuntu’s shell != bash, and how to fix your scripts”

  1. Q Says:

    Thank you for that – exactly what I was looking for :)
    / KingNeutron


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.