原始文本foo.txt内容
IMSI=8671200001;
ISDN=8612345;
IMSI=8671200001;
ISDN=8612345;
IMSI=8671200001;
ISDN=8612345;
IMSI=8671200001;
cat foo.txt | awk '{
if($0 ~ /IMSI=/ {
split($0,imsi_ary,"=")
imsi=gsub(/;/,,imsi_ary[2])
}
print imsi
}'
问什么输出是
1
1
1
而不是想要的
8671200001
8671200001
8671200001
IMSI=8671200001;
ISDN=8612345;
IMSI=8671200001;
ISDN=8612345;
IMSI=8671200001;
ISDN=8612345;
IMSI=8671200001;
cat foo.txt | awk '{
if($0 ~ /IMSI=/ {
split($0,imsi_ary,"=")
imsi=gsub(/;/,,imsi_ary[2])
}
print imsi
}'
问什么输出是
1
1
1
而不是想要的
8671200001
8671200001
8671200001
