Santi
December 26, 2007, 4:51am
1
Dear Folks,
I have a command output something like:
And I want to store PIN0 and SIG0 in two shell variables, now I do a double awk:
PIN=`gsmctl -d /dev/ttyS0 pin sig | awk '/PIN0/ { print $2}'`
SIG=`gsmctl -d /dev/ttyS0 pin sig | awk '/SIG0/ { print $2}'`
It's possible to modify two shell variables only calling one time to AWK? Perhaps defining two shell variables and modifying in a AWK block.. thanks!!
Regards,
/PIN0/ { printf "PIN=%s\n", $2 }
/SIG0/ { printf "SIG=%s\n", $2 }
$ eval `gsmctl -d /dev/ttyS0 pin sig | awk -f awkfile`
$ echo $PIN $SIG
READY 31
Santi
December 26, 2007, 2:17pm
3
fpmurphy, thanks for your reply
I want to use only one script/file.. using awk -f I need at least two files, is there any solution to make this only with one script? perhaps using another way instead of awk? Thanks!!
Regards,
gsmctl -d /dev/ttyS0 pin s | xargs | read X PIN Y SIG
echo $PIN
echo $SIG
rikxik
December 26, 2007, 9:28pm
5
Not nitpicking - the above does not work with sh/bash - only in ksh. This should work with all three:
set `gsmctl -d /dev/ttyS0 pin s |awk '{print $2}'`
echo $1 $2
HTH