[PLUG] Looking For Work In Portland
Wil Cooley
wcooley at nakedape.cc
Wed Feb 7 17:53:02 UTC 2007
On Tue, 2007-02-06 at 13:18 -0800, Cooper Stevenson wrote:
> Hello,
>
> I've recently been asked to share some examples of some scripting
> skills. I thought these might be of interest to you as well--especially
> my geosynchronized photo script.
>
> The first, process_main.sh is one of my favorites. I wanted a system
> that would permit me to automatically create geosynchronized satellite
> maps with labels depicting the exact location of each photo was taken.
> You may view the script online here:
>
> http://cooper.stevenson.name/scripts/process_main.txt
A few points:
1. It's nice to start with comments at the top of script that include
who wrote it, when, a description, etc. Interestingly, I wrote a
template at one time (that I seem to have forgotten about):
http://haus.nakedape.cc/svn/public/trunk/small-projects/dev-utils/script-template
Here's another script that lets you extract POD from comments of shell
scripts, so you can generate man pages:
http://haus.nakedape.cc/svn/public/trunk/small-projects/dev-utils/unhash2pod2man
2. Er, you do know that 'date' can format dates as you like them,
without resorting to sed/awk?
$ date | awk '{ print $2, $3, $6}' | sed 's/ /./g'
Feb.7.2007
$ date +%b.%-d.%Y
Feb.7.2007
Anyway, since it looks like you're using the date for directory/file
names, it seems to me to use ISO-formatting, so dates sort numerically
in order:
$ date -I
2007-02-07
(If you want portability with non-GNU date(1)s you can use the
appropriate format specifiers.)
3. You seem to switch between variables named with '_dir' and
'_directory'. Any particular reason?
4. Comments are easier to read if a space immediately follows the hash
character.
5. You have a couple lines longer than 80-characters, one of which is
really long. Please, think of the kittens.
6. I think it's a good practice when building pathnames in variables to
separate them with '/', even if you plan to always end base paths with
'/'--someone else using or modifying your script might not. I.e.,
image_mount_dir=${base_directory}08.09.06/images/
vs
image_mount_dir=${base_directory}/08.09.06/images/
(Not to mention comp.unix.shell FAQ about always quoting variables.)
7. You don't need to grep something if you're going to immediately pipe
it to awk; awk has a pattern-matching facility:
grep timediff | awk -F',' '{print $1, $2, $4, $5, $6}'
awk -F, '/timediff/ {print $1, $2, $4, $5, $6}'
(The comma doesn't need to be quoted either.)
8. "run: command not found" (You're missing a '#' at the beginning of
the penultimate line.)
9. "perl" not "pearl"
Wil
--
Wil Cooley <wcooley at nakedape.cc>
http://nakedape.cc
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <http://lists.pdxlinux.org/pipermail/plug/attachments/20070207/1e66c51e/attachment.asc>
More information about the PLUG
mailing list