From owner-freebsd-questions@FreeBSD.ORG Wed Jul 27 16:58:19 2011 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9222D1065785 for ; Wed, 27 Jul 2011 16:58:19 +0000 (UTC) (envelope-from perrin@apotheon.com) Received: from oproxy6-pub.bluehost.com (oproxy6-pub.bluehost.com [67.222.54.6]) by mx1.freebsd.org (Postfix) with SMTP id 5CBF98FC12 for ; Wed, 27 Jul 2011 16:58:19 +0000 (UTC) Received: (qmail 6918 invoked by uid 0); 27 Jul 2011 16:58:18 -0000 Received: from unknown (HELO box543.bluehost.com) (74.220.219.143) by cpoproxy3.bluehost.com with SMTP; 27 Jul 2011 16:58:18 -0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=apotheon.com; s=default; h=In-Reply-To:Content-Type:Mime-Version:References:Message-ID:Subject:To:From:Date; bh=w8oOOQGhML855U1SaHWn3DabEdwyzU1FR4y3O0AZLp4=; b=jR1E1yTjkaoS9R865E7rbjilWd6wgoHL/rlEmI0S8EU86FoqY6JgJyjnfboT52JESBGO19VQHpm0NJrNJ+MTHG+GRZ6IK0JFsRnLSolb/zW0lXq+/EJuyrmB+9rCYlAv; Received: from c-24-8-180-234.hsd1.co.comcast.net ([24.8.180.234] helo=kukaburra.hydra) by box543.bluehost.com with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.69) (envelope-from ) id 1Qm7R3-0004HL-Hm for freebsd-questions@freebsd.org; Wed, 27 Jul 2011 10:58:18 -0600 Received: by kukaburra.hydra (sSMTP sendmail emulation); Wed, 27 Jul 2011 10:41:20 -0600 Date: Wed, 27 Jul 2011 10:41:20 -0600 From: Chad Perrin To: freebsd-questions@freebsd.org Message-ID: <20110727164120.GA97293@guilt.hydra> Mail-Followup-To: freebsd-questions@freebsd.org References: <4E2F1C0F.4040108@msen.com> <4E2FC21A.6070300@infracaninophile.co.uk> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="bp/iNruPH9dso1Pn" Content-Disposition: inline In-Reply-To: <4E2FC21A.6070300@infracaninophile.co.uk> User-Agent: Mutt/1.4.2.3i X-Identified-User: {2737:box543.bluehost.com:apotheon:apotheon.org} {sentby:smtp auth 24.8.180.234 authed with ren@apotheon.org} Subject: Re: Book recommendations (slightly OT) X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Jul 2011 16:58:19 -0000 --bp/iNruPH9dso1Pn Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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.= =20 > > 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. >=20 > 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. >=20 > 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. >=20 > 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. >=20 > 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. --=20 Chad Perrin [ original content licensed OWL: http://owl.apotheon.org ] --bp/iNruPH9dso1Pn Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.14 (FreeBSD) iEYEARECAAYFAk4wP7AACgkQ9mn/Pj01uKXJOACfdijl5Kjppu7FkqEuV2IVAtnI xC4AnA429ObNAxj7RDGJSegxnUTX9wRz =dnNH -----END PGP SIGNATURE----- --bp/iNruPH9dso1Pn--