Unix Programming - shell + filter (eng)

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > April 2006 > shell + filter (eng)





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author shell + filter (eng)
Laurent Deniau

2006-04-02, 7:42 pm

(sorry for the previous french version, wrong newsgroup)

I have a string containing a list of tokens separated by spaces (or by
\n after a sed if required) and I would like to remove the last
character of each token if and only if it is a '_' (underscore). Any
Idee? Thanks.

a+, ld.
elrado@abv.bg

2006-04-02, 7:42 pm

echo asdf_asdf asdf_ _asdf asdf asdf__ __ | sed
's/\([[:alnum:]_]\)_[[:>:]]/\1/g'
this one will substitute every occurence of x_ with x, where x is any
alnum character plus _.
[[:>:]] stands for non word boundary. man 7 re_format.

Laurent Deniau

2006-04-02, 7:42 pm

elrado@abv.bg wrote:
> echo asdf_asdf asdf_ _asdf asdf asdf__ __ | sed
> 's/\([[:alnum:]_]\)_[[:>:]]/\1/g'
> this one will substitute every occurence of x_ with x, where x is any
> alnum character plus _.


Thanks.

> [[:>:]] stands for non word boundary. man 7 re_format.


This is what I was missing (not in my man 7 regex = re_format).

a+, ld.
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com