awk存入shell数组


http://www.xxlinux.com/newxxlinux/development/shell/2011-11-28/472.html

ORDER="0e 31 00 22 00 04 02 04 02 "

awk 'BEGIN{split('""$ORDER""',START," ");print START[6]}'
eval $(awk 'BEGIN{split('""$ORDER""',a," ");for(i in a)print "START["i"]="a[i]}')
cat file
0e 31 00 22 00 04 02 04 02
必须要用圆括号括起来
B=($(awk '{print $0}' file))
A=(`awk '{print $0}' file`)
echo ${A[4]}
00
list="0e 31 00 22 00 04 02 04 02 "
START=$(awk 'BEGIN{print "'"$list"'"}')
echo ${START[0]}
0e 31 00 22 00 04 02 04 02
awk从文件与从变量中读取不同

你可能感兴趣的:(awk存入shell数组)