Search code examples
linuxshellunixsolaris

difference between script shell on linux and script shell on solaris


I want to learn shell scripting and I will use solaris in my work. Is there any difference between shell scripts on linux and shell scripts on solaris?


Solution

  • The difference is not between Linux and Solaris, the difference is between which shell you are using on each: sh, csh, ksh, zsh, bash etc.

    When you write a shell script you should always start it with a shebang indicating what shell the script is written for. For example
    #!/bin/bash
    or
    #!/bin/csh

    Note shebang also works for scripting in non-shell languages:
    #!/usr/bin/perl
    #!/usr/bin/python

    The bash shell is now commonly available nearly everywhere, and I suggest that's the one you learn if it's available on you Solaris system.
    /bin/sh is the POSIX shell and you should learn that, and the differences between it and bash.

    ksh is an improvement over sh, as is zsh (but zsh claims it "is a shell designed for interactive use")

    csh is considered evil

    These days bash and sh are the ones to learn.