小编cod*_*ja7的帖子

为什么使用awk的数组输出不正确?

我有一个字符串:Gatto piu bello anche cane在文件中.我使用awk分割它并将其放入数组.但输出的顺序不正确.我的代码是:

while (getline < "'"$INPUTFILE"'") {
        text = $0;
}
split (text,text_arr," ");
for (i in text_arr) {
    print text_arr[i];
}
Run Code Online (Sandbox Code Playgroud)

$INPUTFILE 是该字符串的文件.

但是这段代码的输出是:

anche
cane
Gatto
piu
bello
Run Code Online (Sandbox Code Playgroud)

我不知道是什么问题.

arrays awk

2
推荐指数
1
解决办法
713
查看次数

标签 统计

arrays ×1

awk ×1