Saturday 10 November 2018

unix - What is the difference between bash and sh?


I see two types of code being used:


#!/usr/bin/sh

and:


#!/user/bin/bash

I searched for this online and opinions vary a lot. The explanations I saw on most websites say that sh is older than bash, and that there is no real difference.


Does someone know the difference between these? Can you give me a practical example when to use one over the other?



Answer



bash is a superset of sh ie. everything you can do in sh you can do in bash.


Bash has more features (branching, builtins, arrays) making script easier to write. Some later *nix'es have /bin/sh as a link to /bin/bash


For a full explanation of what here's a tutorial


No comments:

Post a Comment

Where does Skype save my contact's avatars in Linux?

I'm using Skype on Linux. Where can I find images cached by skype of my contact's avatars? Answer I wanted to get those Skype avat...