On Wed, 28 Jun 2006, Curt Duncan Taylor wrote:
> It appears that I am using tcsh and have chosen a scripting language
> for which there is no ready reference. I'll google a bit before I try
> changing to bash.
Community members have already pointed out several sites for
further information. If you are determined to use tcsh for
this (and other) scripts, I may still have an old O'Reilly
book on Csh and Tcsh that you may borrow indefinitely.
> I suspect that when I make the change everything will blow
> up and I will wish I had switched to Perl several months
> ago. Oh well.
As others have pointed out, if you include the #! line as
the first line in your script, you can use whatever
interpreter you wish for this script (bash/perl/python)
without affecting any other scripts you've already written.
> Course I still don't know how to write an 'if' statement, but may be
> able to get beyond random combinations of if, then, then;, end-if,
> endif, fi, -if etc. etc. ad insanitatum.
Folks have kindly shared basic if-then syntax for bash,
tcsh, and perl in response to your original request.
Usually, though, the challenge of flow-control is the
conditional statement, not the structure of the statement.
We are lucky enough to have the Safari Tech Books online
available to us through the library (Thank you!). This
includes the entire contents of O'Reilly's excellent text:
Learning the bash Shell, 3rd edition.
http://proquest.safaribooksonline.com/0596009658
[must be on campus, physically or via VPN]
Chapter 5 describes flow-control statements, including
if/else.
If you haven't worked with Perl yet, current wisdom is that
you might do better to start with Python instead.
Learning Python, 2nd Edition
http://proquest.safaribooksonline.com/0596002815
But some of us really love Perl, and there are lots of good
resources out there for Perl, too. Among many others, see
Learning Perl, 4th Edition
http://proquest.safaribooksonline.com/0596101058
Enjoy the adventure, whichever path you choose.
--Geoff
|