Server Fault is a question and answer site for system and network administrators. 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

I am new to Unix shell scripting. So can anybody help me?

How to write shell scripts in Sun Solaris? How to run/execute the script?

Please post in detail.

share|improve this question
i have very good skills in C++ language – Mohammad AL-Rawabdeh Sep 13 '10 at 7:50
Shell scripting is very different to c++ so the learning curve might be quite steep. Check out its aimed at Linux OS's but the principles are largely the same. – chunkyb2002 Sep 13 '10 at 8:07
This is outside the scope of server fault. A common shell to script in is bash - you can find an introduction to bash scripting here – Iain Sep 13 '10 at 8:10
up vote 1 down vote accepted
  • create script file, first row beginning with this: #!/bin/sh -
  • add script body (echo Hello world) on following lines after that.
  • make script executable (chmod u+x scriptfile)
  • either put scriptfile somewhere in your path, or invoke it by its pathname.

./scriptfile is the relative pathname if your current directory is where you put the script.

share|improve this answer

It is not very different from writing a shell script in Linux. Some pitfalls:

  • Relying on GNU tools, but not installed (sed, awk, grep -r etc.)
  • Path names (if you use bash, prefix all your scripts with #!/usr/bin/env bash

I suggest you to read

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.