获取A7_p关键字所在列
pnum=`cat outlet.csv| grep 'A1_U'| awk -F "," '{;for(i=1;i<=NF;i++)if($i ~ /A1_U/)num=i;printf num}'`
获取包含A关键字的列及列名
cat outlet.csv| grep 'A' | awk -F "," '{;for(i=1;i<=NF;i++)if($i ~ /A/) printf "%-5s %s\n",i,$i }'
2 A0_Conversion
3 A0_Seclective
4 A1_CH4
5 A2_C2H4
6 A3_C3H6
7 A4_C3H8
8 A5_C4
9 A6_C5
输出包含A关键字的列前两行的值
Aindex=$`cat outlet.csv| grep 'A' | awk -F "," '{;for(i=1;i<=NF;i++)if($i ~ /A/) print i }'| xargs| sed -e 's/ /,$/g'`
echo $Aindex
awk -F "," ' NR==1 || NR==2{ print '$Aindex' }' outlet.csv