0

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?

1
  • The default shell in most versions of Linux and Solaris (as well as mac's OSX) is bash. Most stuff will be the same. You can also write scripts in perl or python, which also should be available. Commented Jan 27, 2017 at 1:50

2 Answers 2

3

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.

Sign up to request clarification or add additional context in comments.

1 Comment

/bin/sh is the POSIX shell... Be careful. Because Linux tends to entirely conflate sh and bash - sh may even be softlinked directly to bash. Solaris doesn't do that. Many are the Linux "sh" scripts that fail on Solaris because of bashisms.
0

thank you all. What I understood from your replies that I have to learn the bash shell which is compatible with linux and solaris.

1 Comment

Your conclusion is right, but you should say thank you by accepting the answer of @stephen.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.