Unix Shell - Passing a shell parameter to awk

This is Interesting: Free IT Magazines  
Home > Archive > Unix Shell > December 2007 > Passing a shell parameter to awk





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]

Author Passing a shell parameter to awk
apogeusistemas@gmail.com

2007-12-19, 1:39 am

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.
Vakayil Thobias

2007-12-19, 1:39 am


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

>cat script

memory=20480
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.



Janis

2007-12-19, 7:32 am

On 19 Dez., 03:14, apogeusiste...@gmail.com wrote:
> Hi:
> please, how can I pass a shell parameter to an awk command ?
>
>
> 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
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com