Home > Archive > Unix Programming > February 2007 > awk gsub command
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]
|
|
| james.mork@gmail.com 2007-02-23, 7:10 pm |
| Hi,
I am new to awk scripting and trying to figure how to use gsub
command.
In this example:
gsub(/^[ \t]+|[ \t]+$/,"",mgev_tx)
what is /^[ \t]+|[ \t]+$/ doing?
| |
| Jens Thoms Toerring 2007-02-23, 7:10 pm |
| james.mork@gmail.com wrote:
> I am new to awk scripting and trying to figure how to use gsub
> command.
> In this example:
> gsub(/^[ \t]+|[ \t]+$/,"",mgev_tx)
> what is /^[ \t]+|[ \t]+$/ doing?
The '^[ \t]+' bit means at least one (or more) spaces or tab
characters at the beginning of the string and the '[ \t]+$'
means at least one (or more) spaces or tab characters at the
end of the string. The '|' means 'or', so this matches all
spaces/tabs at the very start or the very end of a string.
Looks like the wole thing is meant to remove all white space
the start and end of a string stored in 'mgev_txt'.
Regards, Jens
--
\ Jens Thoms Toerring ___ jt@toerring.de
\__________________________ http://toerring.de
|
|
|
|
|