[wplug] Script to import TXT into mySQL

Bryan J. Smith b.j.smith at ieee.org
Thu Jul 26 20:55:17 EDT 2007


On Thu, 2007-07-26 at 20:43 -0400, Kevin Squire wrote:
> So my question... How can I make sure that MAILADDRESS does not get any
> accidental trailing white spaces?  I don't want "user1 at example.org   "
> to go into my database.

Pipe through sed with the "-n" option and "p" match ...

  sed -n -e 's/[\t ]*\([_-. at 0-9A-Z]\+\)[\t ]*/\1/ip'

The "p" match with "\1" tells it to return the first parenthesis match,
which I've put both a leading and trailing whitespace outside of that
parenthesis match.

> also, if anyone has a more elegant way to do this, I would be happy to
> hear it :-)

It's not my way is the most elegant, but I've become pretty reliant on
"sed" because it works nearly _verbatim_ under Busybox compared to the
full version (whereas other tools are not).


-- 
Bryan J. Smith         Professional, Technical Annoyance
mailto:b.j.smith at ieee.org   http://thebs413.blogspot.com
--------------------------------------------------------
        Fission Power:  An Inconvenient Solution



More information about the wplug mailing list