linux music tools It is quite possible and was done all the time in the bad

martin McCormick martin.m at
Wed Jul 29 15:48:54 UTC 2015

Nobody has mentioned regular expressions yet. They are part of
the life blood of unix. For those who are new or haven't strayed
very far outside of DOS-type commands, regular expressions are
sets of rules that describe generalities or traits rather than
specific expressions such as the BBC program files mentioned
earlier or a zillion other cases where one is looking for a
general rule that describes countless specific cases.

	I use a mail program called procmail which sorts incoming
mail and puts it in to folders based on who sent it. Like many
unix utilities, it lives and breathes regular expressions so you
don't have to write 50-thousand rules for essentially the same
condition. An example is as follows:

I get mail from my old email address which is martin at
This mail first comes from a spam-blocker that is part of our
Microsoft outlook exchange mail system and messages that the spam
blocker thinks smell spammy are flagged with a header that
contains the word "spam" plus a number from 0 or 1 to 100 which
is the blocker's assessment of the likelyhood that this message
is spam based on a formula the spam blocker uses. This means I
get messages that may say, "Adult-Spam [94]" or something
similar. I could do it the hard way and write 
"Adult-Spam [90]"
"Adult-Spam [91]"

and so on up to 99 and it would work and put any messages
containing one of these lines right in to the bit bucket or I can
put two lines in my procmail control file that read:

* ^Subject:.*\[Adult Spam: [0-9][0-9]\]

Here's the English translation.

* ^Subject:.*

This regular expression tells procmail that we are looking for
any line whose very first word is Subject: This includes the : character.

The * after the : is the regular expression or RE way to say, I
don't care what follows after this.

Continuing on,
\[Adult Spam: 

We're looking for the words "adult spam:"


Now, there's some real magic. The [ says we are starting a
regular expression or RE. The 0-9 says the next character can be
any number from 0 through 9. The ] says that this is the end of
what we are looking for for the first digit but the next [0-9] says we
are also looking for a second digit so altogether, we are looking
for any two digits between 00 and 99.

	The \[ and \] tells the regular expression filter that
those brackets are actually real bracket characters and don't mix
them up and think it's a regular expression.

/dev/null is the proper unix destination for all those
wonderful business opportunities that I might choose if I wasn't

	so, what I just told you is that that one line directed
procmail to key on any line whose first word is "subject:", whose
next two words are "adult spam:" and whose next two characters
are digits from 0 through 9. Ignore all other lines that don't
fit this rule.

	Hey, if you're confused, I've been doing this for 26
years and I still have to really scratch myhead to make RE's

	You also must not forget that regular expressions are
everywhere in unix from commands you type at the shell prompt all
the way up to high-level scripting and programming languages so
the more you learn about them, the more problems you can solve.

	You should have a man page to get your journey down the
rabit hole started so try

man regex

	Finally, I can't warn you strongly enough. Unix is
industrial-strength power tools. Most of you are adults and you
can do real harm to your system if you don't backup important
data. These tools will do exactly what you tell them to do, not
always what you were hoping they would do.

	In other words, if you wreck it and didn't have a backup,
consider it tuition in the school of hard knocks.
	I am sure I have confused enough people if you are still
reading this so let's let the smoke clear for now.


More information about the Blinux-list mailing list