scripting help needed, please

Bill Maltby LFS Related lfsbill at wlmcs.com
Thu May 9 19:56:22 PDT 2002


On Thu, 9 May 2002, Rob 'Feztaa' Park wrote:

> Alas! timothy bauscher spake thus:
> > > >   sed -e 's/\(.*[^ ]\)  *-  *\([^ ].*\)$/\1-\2/' \
> > > >       -e 's/\([^- ][^- ]*\) /\1_/'
> > >
> > > You trying to make my eyes go blurry? :o)
> > >
> > > I will try this asap. Thank you very much!
> > 
> > i just drooled for a while when i saw that.
> > it looks like jibberish to me. i have a book
> > on sed and awk [orielly], but i have been
> > putting it off ...
> 
> Don't beat yourself up too much. It's more complicated than it needs to
> be.

Hmm. I never thought of it as complicated. Just the difference between
"you" and 'y'all".

> 
> The sed construxt "xx*" (where 'x' is anything, like " " or "[^- ]") can
> be simplified to "x\+". So it can be simplified to this without changing
> what it actually does:
> 
> sed -e 's/\(.*[^ ]\) \+- \+\([^ ].*\)$/\1-\2/' \
>     -e 's/\([^- ]\+\) /\1_/'

Old habits die hard. Didn't used to be a '+'. Even after I learned
about it, I still keep using what I first learned. I only use the
plus (and other later additions) early in the day when I am actually
*thinking*.

> 
> But you could just do this instead, with exactly the same effect:
> 
> sed -e 's/ *- */-/g' -e 's/ \+/_/g'
> 
> (actually, it's not exactly the same, but it more accurately
> accomplishes what was asked)
> 
> Have fun ;)

You did! :-)

> 
> -- 
> Rob 'Feztaa' Park
> http://members.shaw.ca/feztaa/

Bill Maltby
billm at wlmcs.com

-- 
Unsubscribe: send email to listar at linuxfromscratch.org
and put 'unsubscribe blfs-support' in the subject header of the message



More information about the blfs-support mailing list