Enterprise Unix Roundup: The Linux World's Newest Big Wheel Page 2

By Michael Hall (Send Email)
Posted Mar 25, 2004


Main   In Other News     Security Roundup     Tips of the Trade

Security Roundup

The biggest security item this week is a denial-of-service vulnerability in OpenSSL. Vendors with patches out include HP, Fedora, Trustix, OpenPKG, Slackware, Gentoo, Debian, Red Hat, FreeBSD, and En Garde Secure Linux

Tips of the Trade

Sometimes it's useful to pass the output of one program as an argument to another, or assign the output of a command to a variable. In the Unix shell world, that's where backquotes come in.

Here's a simple example:

Suppose you want to write a log backup script that stores files in a series of directories named for the date on which the script runs. With backquotes, you can couple the command mkdir with a backquoted execution of the date command to create a directory with the month and year appended to its name.

mkdir logs_`date +%m%y`

will create a directory called logs_0304 (assuming this command is run in March 2004).

The advantage of using backquotes in this sort of context is pretty clear. A command expressed only once (and we'll admit, we're forever looking up the syntax for date alone) can be reused to return dynamic information in scripts, making them much more reusable and simple.

find is another candidate for using backquotes. We periodically find ourselves with many source archives laying around, and we like to round them all up into a central directory where we keep pristine sources from developers. One way to do that using backquotes and find might be a command, like:

mv `find ./  -iname "*tar.gz"` ~/sources/

In that case, the find command tracks down every file in the current directory and its subdirectories with the suffix tar.gz. It returns that as an argument to the mv command, which puts them in the directory called "sources" in our home directory.

And here's one more bonus application of backquotes and dates for the ever-popular Unix mail client mutt. Mutt maintains close ties to the Unix system running underneath it. It's possible, in fact, to create custom commands using Unix commands. Here's a line from our .muttrc file that handles creating a custom-named directory to sort our sent mail by month:

set record = =sent_`date +%m%y`

Using that, each time you send a mail, a copy will be automatically filed into a folder in the mail directory called "sent_MMYY", where "MM" is the current month and "YY" is the current year.

Light Reading

We like pointing to the occasional Unix culture piece, and we were happy to rediscover an essay titled "The Elements of Style: Unix As Literacy." We especially recommend it for all those former English majors out there who now find themselves tending a Unix box -- and maybe even enjoying it.

>> To Main
>> To Other News

Page 2 of 2


Comment and Contribute

Your name/nickname

Your email

(Maximum characters: 1200). You have characters left.