Book recommendations (slightly OT)
perrin at apotheon.com
Wed Jul 27 16:58:19 UTC 2011
In the following, I cut out anything not needed as context for my
response. Where I cut something out, you should assume that I agree with
what Matthew Seaman wrote, and have nothing in particular to add to it at
this time. The only possible exception is the specific list of resources
he suggested for learning shell scripting, but only because I am not
personally familiar with all the recommendations and thus am not in a
position to comment on them.
On Wed, Jul 27, 2011 at 08:45:30AM +0100, Matthew Seaman wrote:
> On 26/07/2011 20:57, Mark Moellering wrote:
> > I want to automate some tasks, creating directories, file editing, etc.
> > I was going to pick up a book on shell scripting but wanted to ask the
> > list if;
> > A) I am barking up the wrong tree and should use something else.
> No -- automating routine tasks is exactly what shell scripting is for.
Actually, he said "automating tasks" with no specific reference to
*routine* tasks, and I'd say that pretty much anything involving
computers is about automating tasks -- especially scripting/programming.
As you suggest, though, the more routine these tasks are (particularly as
system administration tasks), the more likely they are to be exactly the
right time to use shell scripting.
> First of all, choose your shell. On FreeBSD I'd say that it's got to be
> /bin/sh for programming. This is the POSIX compatible Bourne Shell. If
> you write your scripts to the POSIX standard then you'll be able to run
> them just about anywhere eg. using bash on a Linux box. The converse is
> not true.
> You could learn bash -- it is pretty much a de-facto standard nowadays
> -- but bash is pretty bloated with lots of interactive usage stuff, and
> there's nothing you can't do in POSIX shell that you can in bash. Also,
> bash has to be installed from ports, which might not seem like a big
> deal (usually it isn't), but it tends to become really quite important
> when you're dealing with systems in extremis.
> Don't bother trying to use tcsh for programming -- that's not what it is
> for. tcsh is great interactively (it's what I use for my login shell),
> but a pain in the bum for scripting.
I would say that the Bourne shell (that is, /bin/sh) is the right choice
for pretty much *all* shell scripting. If you need more than the Bourne
shell, or its POSIX compatible equivalent, you should be using a high
level programming language such as Perl or Ruby instead of an interactive
shell syntax. More sophisticated shells are fine for interactive use,
but should not be relied upon for shell scripting in the vast majority of
cases for reasons of portability and consistency.
Chad Perrin [ original content licensed OWL: http://owl.apotheon.org ]
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 196 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20110727/e70582d8/attachment.pgp
More information about the freebsd-questions