08 Jun

How to learn shell scripting for OS X

Terminal in Mac OS X

I was recently asked what the best way to learn about shell scripting and the Terminal is for OS X.

The commands available in Terminal can be very powerful, and combining them in a shell script can help you achieve some very impressive things and save yourself a lot of time. And you can combine shell scripts with Automator to make some really cool tools.

Of course, a powerful tool in untutored hands also be pretty dangerous. So it’s important to be sure you know what you’re doing.

The first thing to remember is that when you’re working in Terminal, you’re in a bash shell on a UNIX system. Unix has been around a long time so there are plenty of guides available.

Where to start?

Many moons ago when I was first dabbling with shell scripting, I tried a few books and nothing really clicked until I read this book:

Learning Unix for OS X by Dave Taylor

Click book cover image to view book details

It’s a really good beginner’s guide to UNIX, directly focussing on OS X.

Going deeper…

If you get to grips with Learning Unix for OS X and still crave more information then try:

Click book cover image to view details

Click book cover image to view book details

…just bear in mind that Unix in a Nutshell is a general guide to UNIX rather than OS X specific. That said, the vast majority of it will be applicable and it’ll give you a very comprehensive understanding of UNIX. I know several UNIX system admins who have a sneaky copy of it in a bottom drawer as a handy reference.

Other guides

Of course, there are plenty of good online guides, for example this one:

BASH Programming – Introduction HOW-TO

…and there’s a course on Lynda.com which looks good at first sight, although I’ve not used it so I can’t comment.

If you don’t have time to learn to shell script or if you can’t figure out how to do something then don’t forget that we do custom development at very reasonable rates. Get in touch via our support page for details.