Lesson 6 - Advanced Topics
Required Reading
- Learning
UNIX: Chapter 8 (Where to go from here)
- WWW: Introduction
to Shell Scripting -- The Basics
- WWW: sed
& awk FAQ
Additional Notes
Shell scripting can be a UNIX webmaster's best friend, especially
when combined with cron. Automate, automate, automate, and
leave youself some free time to enjoy the big bucks you're
earning in the dot-com economy. :-)
An interesting thing to observe about shell scripts is how
similar they appear to perl scripts. Both are interpreted
languages, meaning you don't have to compile them befoer you
run them (like C or C++) and both start with the famous "shebang"
line (#!/bin/sh). Also the term "script" is often
used in association with CGI programs (the defacto standard
for web programming). That is because CGI programs were originally
nothing more than small scripts (ie. a short sequence of commands
to run on the server), although now days they are really full-blown
application programs.
We talked about the UNIX filter grep back in Lesson
4, and you saw how you can use it to do complex searches of
files on your system. The utilities sed & awk
are also filters, but they are also much more. sed
is very useful for editing multiple files at the same time
(say, for example, you need to update a bunch of HTML files
with a change to your email address). On the other hand, awk
is esentially a mini programming language that will let you
build sophisticated reports, particularly when dealing with
structured datafiles. Here's a simplistic example: if you
had a set of files, each containing the address of a friend,
you could easily use awk to compile a list of your
friends in order of their zip code. These are very powerful
tools and can save you a lot of time when you need to do advanced
administration tasks. They are also fairly complex to master,
so I'm just giving you an overview of the possibilities here.
For more in-depth material, I highly recommend O'Reilly's
sed
& awk Nutshell handbook. Also note that you can do
a lot of the same types of things with perl.
Now that you've got the basics under your belt, you'll need
to know where to look when you are presented with more advanced
UNIX challenges. There are many, many UNIX resource sites
around the WWW, and here are a few to bookmark for future
reference:
Next Step
Take the self-quiz
Please complete the course
evaluation.
You're done!
|