tbh wrote:
> hi, i'm not a complete awk beginnger, but also no expert.
>
> I'm trying to do something reasonably simple and am having trouble. i
can do
> the same thing in perl, but my case (reading pretty massive input under
> cygwin under windows) that degrades performance.
>
> I'd like to use a variable as part of a regular expression as follows:
> $ unpackHourlyWebLogs.bash 11 | gawk '(tolower($5) ~
("^/"+base+"/"))
> {print $3,$5,$6}' base="f30" | head
> SVWEB01 /f30/Images/diverse/bg_htab1.gif -
> SVWEB01 /f30/Images/wetter/Gewitter.gif -
> SVWEB01 /m/{EE71E7A4-8115-4F21-AED0-328011C2079C}Picture.GIF -
> ...
>
> unfortunately my output includes matches and non-matches ($5 should
begin
> /f30/ in this example, but the 3rd hit begins /m/. i also tried
initializing
> the pattern matching string in the BEGIN clause (which might also help
> performance?), but that didn't help.
>
> maybe a seasoned (g)awker can spot my mistake?
The biggest problem is that string concatenation is *not* the '+',
instead construct a string like this...
"^/" base "/"
Janis
>
> i'd be grateful.
>
> Tim Hanson
>
> p.s. i meant to simplify the example considerably, but this time i
matched
> nothing, e.g.:
> echo "/a/|/b/" | tr '|' '\n' | gawk 'BEGIN {pat=("^[/]" + base +
> "[/]");} (tolower($5) ~ pat) {print $3,$5}' base="a"
>
>


|