我有一个空格分隔的文件:
Pool Library Name Email Subject
Finland lib1 Guru guru@abc.com,Narendra@abc.com Finland Media Rotation
Tucson lib2 Albert abc@def.com Tucson Media Rotation
Vancouver lib3 Jeff ghi@abc.com Vancouver Media Rotation
我想将列解析为数组,例如:
declare -a Pool=(Finland Tucson Vancouver)
declare -a Library=(lib1 lib2 lib3)
declare -a Name=(Guru Albert Jeff)
declare -a Email=("guru@abc.com,Narendra@abc.com" abc@def.com ghi@abc.com)
我的代码是:
column=1
for arrayname in Pool Library; do
mapfile -t "$arrayname" < <(awk "NR > 1 {print \$$column}" file.txt)
((column++))
done
但是如果有多个项目,例如 in ,它就会失败Email
。