Passing a shell parameter to awk

Hi:
please, how can I pass a shell parameter to an awk command ?

>cat script
memory=3D20480
value=3D1380
echo $value | awk =B4{ calc=3D$memory-$1*8192/1024/1024}=B4

Thanks.
apogeusistemas [ Mi, 19 Dezember 2007 03:14 ] [ ID #1889960 ]

Re: Passing a shell parameter to awk

<apogeusistemas [at] gmail.com> wrote in message
news:4cd7d9d1-1678-41e3-aa77-e082b40492a6 [at] d21g2000prf.google groups.com...
Hi:
please, how can I pass a shell parameter to an awk command ?

>cat script
memory 480
value=1380
echo $value | awk ´{ calc=$memory-$1*8192/1024/1024}´

Thanks.


echo $memory $value | awk '{print $1 $2}'

the variable $memory will pass as $1 and $value will be pass as $2 in awk.
Vakayil Thobias [ Mi, 19 Dezember 2007 05:33 ] [ ID #1889962 ]

Re: Passing a shell parameter to awk

On 19 Dez., 03:14, apogeusiste... [at] gmail.com wrote:
> Hi:
> please, how can I pass a shell parameter to an awk command ?
>
> >cat script
>
> memory=3D20480
> value=3D1380
> echo $value | awk =B4{ calc=3D$memory-$1*8192/1024/1024}=B4
>
> Thanks.

echo $value | awk -v m=3D$memory '{ calc=3Dm-$1*8192/1024/1024}'

Janis
Janis Papanagnou [ Mi, 19 Dezember 2007 10:35 ] [ ID #1889965 ]
Linux » comp.unix.shell » Passing a shell parameter to awk

Vorheriges Thema: Re: cdrtool for solaris 10 x86
Nächstes Thema: Re: What does ${1+"$@"} mean?