On Tue, Sep 14, 2004 at 05:03:41PM +1000, Robert Thorsby wrote:
> On 2004.09.14 16:05 Alexander Samad wrote:
> >> Wouldn't it be a lot easier to use awk's -v option (that's the
> >> reason it's there):
> >> #!/bin/bash
> >>
> >> TEST="Here"
> >> echo "is a test" |
> >> /usr/bin/awk -v i="$TEST" '{print ("\"" i, $0 ".\"")}'
> >
> >Cool learn something new, but does it work in the // regex part ?
>
> I don't follow what you mean by "but does it work in the // regex
> part?" but in awk any variable that is declared by the "v" option can
> be used, modified, changed, etc in the same way as an awk variable that
> is defined within the substantive awk script.sorry my lack of the right words, can you use awk variable in the // part of awk (pattern part) But I think somebody answered elsewhere that variables can't be used there > > AFAIK awk cannot export back into the shell so you have to resort to > either making awk write to a [temp] file or turning the entire awk part > of your script into a variable. > > Robert Thorsby > -- > SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ > Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html >
signature.asc
Description: Digital signature
-- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html
