我正在寻求帮助从文件中读取文本并将其传递到带有空格的数组中。
我的文件是:
Pool Library Name
Backup Lib1 "Guru Singh"
clone Lib2 Raju
Tape Lib3 Deepak
我的代码是:
column=1
for arrayname in Pool Library Name; do
mapfile -t "$arrayname" < <(awk "NR > 1 {print \$$column}" file.txt)
((column++))
done
echo ${Pool[@]}
echo ${Library[@]}
echo ${Name[@]}
输出是
[root@Server MM]# echo ${Pool[@]}
Backup clone Tape
[root@Server MM]# echo ${Library[@]}
Lib1 Lib2 Lib3
[root@Server MM]# echo ${Name[@]}
" Raju Deepak
在echo ${Name[@]}
输入
我想要输出为
Guru Singh Raju Deepak
任何想法/帮助?