【发布时间】:2020-04-14 07:51:06
【问题描述】:
谁能解释一下为什么以下不起作用?
列表
the letter is d
the number is 4
the number is 2
the letter is g
脚本.sh
#!/bin/bash
cat "$1" | grep letter | array=($(awk '{print $4}'))
for i in "${array[@]}"
do
:
echo $i
done
如果我运行此bash script.sh list,我希望数组打印 d 和 g,但事实并非如此。我认为这是因为我试图设置数组。
【问题讨论】: