views:

116

answers:

4

I want to learn how to write shell scripts.

Particularly I want to write a svn post-commit script to upload files from a test server to a production server. I am sure I will want to write more as I get more into it.

I have very little linux/unix knowledge. Can anyone recommend a good book?

+2  A: 

Learning the bash Shell (O'Reilly)

William Leara
Question was actually about the Bourne shell
anon
bash = "bourne again shell" -- the modern update to the Bourne shell.
William Leara
Whats the difference of bourne vs bash? Which one is #!/bin/sh on ununtu? .. should I learn bash over bourne?
John Isaacks
@Neil, the Bash (Bourne-Again SHell) is the closest to the Bourne shell anyone's going to find these days. Yes, it does more than the original Bourne shell, but you can restrict it (use `sh` instead of `bash`) to the original sh functionality. It's not like William recommended a book on the C-shell.
Craig Trader
Does that mean C++ is the same thing as C? Perhaps the OP actually wants to write real Bourne shell scripts for portability purposes. Bash has thousands of differences from Bourne (and yes, I've used them both extensively).
anon
I actually only put bourne because the turorial I was reading had !#/bin/sh ... and I looked up sh to be bourne. if bash is the better thing to learn than I would rather learn bash
John Isaacks
@Neil, are you going to answer the question -- or just pick nits?
Craig Trader
@John If you don't need to work on older UNIX systems, use bash - I've edited your question to reflect this.
anon
@John – In Linux, `/bin/sh` is actually a symbolic link to the default shell. As Ubuntu's website [tells](https://wiki.ubuntu.com/DashAsBinSh): “In Ubuntu 6.10, the default system shell, `/bin/sh`, was changed to `dash` (the Debian Almquist Shell); previously it had been `bash` (the GNU Bourne-Again Shell). […] The default login shell remains `bash`.”
Marcel Korpel
On Solaris, /bin/sh is honest-to-God Bourne shell, so not knowing the differences can lead to a world of hurt...
Jim Lewis
@Neil Butterworh and @Marcel Korpel Thanks guys...I am actually using Ubuntu 10.04, so should I be using bash or dash? there doesn't seem to be near as much literature out there on dash. Thanks.
John Isaacks
@john: `bash` is what you're after.
Craig Trader
A: 

not sure about a book, but here is a decent website I goto for quick reference's and stuff.

note they also have some tutorials you can work your way through.

found here: steve-parker.org/sh/intro

Tree77
+1  A: 

For an online reference, I recommend Advanced Bash-Scripting.

While it's called advanced, it also teaches the basics.

R Samuel Klatchko
A: 

If you want a book that will teach you how to program for Unix (including the original Bourne shell), then I strongly recommend The Unix Programming Environment. It will teach you how to 'think in Unix'. Of course, most of the shell-specific things are out of date (the book was written in 1984).

For a more modern approach to writing Bourne/POSIX shell scripts, then O'Reilly's Learning the bash Shell is a good starting point.

Craig Trader