views:

41

answers:

3

I'm not sure if this is even possible, but is there a way to write shell scripts that can be interpreted by both the Bourne shell as well as C shell? I want to avoid simply checking for the shell and running a shell-specific code. If this is possible, are there any guides on how to do it?

I have always written my scripts for Bourne shell syntax, and I know next to nothing about csh, so this may be a stupid question. I have Google'd for the differences between shells, but there is little information (as far as I can tell) on its implications for scripting.

+2  A: 

If your script is simple a suggest using:

#!/bin/sh

This shell is (almost?) always available.

compie
A: 

you can try reading this book. otherwise, learn to use a language like Python or Perl. Its basic programming syntax, eg flow control, data structures, loops are almost all standard across older and newer versions.

ghostdog74
+1  A: 
Norman Ramsey