1834883 Members
2715 Online
110071 Solutions
New Discussion

Re: awk help

 
SOLVED
Go to solution
Keith Floyd
Advisor

awk help

Hi
How do "export" variables in a script from within awk to "outside" awk

cat /tmp/file | awk '{
if($0 ~ "Fred")
{
F1=$1;
F2=$2;
}
}'

ie I want to use F1/F2 with some HP commands like lvdisplay ..

Thanks as always

Keith
2 REPLIES 2
Danny Engelbarts
Frequent Advisor

Re: awk help

Keith,

Try the following;

for LV in $(awk ' $0 ~ "Fred" {print $1 $2}' /tmp/file)
do
lvdisplay $LV
done

Greetz, Danny.
Andreas Voss
Honored Contributor
Solution

Re: awk help

Hi,

just another version:

set -- $(awk '/Fred/{print $1,$2}' /tmp/file)
F1=$1
F2=$2

Regards