On 3/14/2008 7:15 AM, tbh wrote:
> "Janis" wrote in message
> news:18784f90-e0de-450c-8c93-a91d5dee36d4@[EMAIL PROTECTED]
>
>
>>>i guess it's instructive to me that this appears non-trivial (and even
a
>>>bit
>>>controversial?) in a language as mature as awk.
>>
>>No, it is trivial. Any "non-triviality" here stems from shell
>>quoting issues and from mixing shell level and awk level code.
>>I also think it hasn't been controversial (at least comparing
>>suggestions amongst posters of a similar experience).
>>
>>(Some non-trivialities will appear if your dynamic regexps
>>contains regexp meta-characters.)
>
>
> thanks, that was perhaps careless of me. maybe we could agree on
"trivial"
> in theory, sometimes non-trivial (or non-portable? or potentially
> troublesome in some cases?) in practice.
>
> speaking of which, i now got this to work in cygwin and under linux
>
> echo "/a/|/b/" | tr '|' '\n' | awk -v base="a" '($1 ~ "/"base"/")
> {print}'
printf "/a/\n/b/\n" | awk -v base="a" '$1 ~ "/"base"/"'
> so I'm a happy camper.
>
>
>>(BTW, since it hasn't been mentioned yet; to avoid problems
>>with quoting you can put the awk program in a file and call
>>it using awk's -f option. As a side effect you are forced to
>>use a cleaner and more robust way to pass shell variables.)
>
>
> good to know, thanks. i have occasionally used awk that way in the past,
but
> get a lot of great mileage with one-liners in the middle of pipes. the
> challenge becomes how to file away the useful ones for future recycling.
:)
>
> cheers, Tim
>
>


|