learning script

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Victor Odhner
Date:  
Subject: learning script
Matt Alexander wrote:
> On Sun, 18 Jan 2004, Craig White wrote:
>>GOOD IDEA to put on the first line of any shell script you write...
>>!#/bin/sh
> Or even #!/bin/sh ;-)


I would strongly suggest that you do "man bash" and
read the whole thing through one time. Very revealing.
It helps you really understand what a shell is,
and that lets you script more intelligently.

Here's a cool little example. Put this into a
file, make it executable and run it. It will
print itself:

#!/bin/cat
hello world

In this case, /bin/cat is the "command interpreter",
and it "runs" the file by echoing its lines to
standard output.

Question: is there a pure Bourne shell (sh) in
the Free Software domain? My Linux system links
"sh" to "bash". Since Bourne is the "universal"
command interpreter, the one you can count on
being everywhere, most sysadmins in the past have
made a practice of writing most scripts for Bourne.
This ensures portability. Sort of like knowing VI
because it's available on any *nix platform, where
you might not find emacs. Bash emulates sh, but
is there a way to tell it to behave as "pure" sh?
"Man sh" takes me to the "bash" man page.

Vic