I have a space-delimited file:
Pool Library Name Email Subject
Finland lib1 Guru [email protected],[email protected] Finland Media Rotation
Tucson lib2 Albert [email protected] Tucson Media Rotation
Vancouver lib3 Jeff [email protected] Vancouver Media Rotation
I want to parse the columns into arrays like:
declare -a Pool=(Finland Tucson Vancouver)
declare -a Library=(lib1 lib2 lib3)
declare -a Name=(Guru Albert Jeff)
declare -a Email=("[email protected],[email protected]" [email protected] [email protected])
My code is:
column=1
for arrayname in Pool Library; do
mapfile -t "$arrayname" < <(awk "NR > 1 {print \$$column}" file.txt)
((column++))
done
But it's failing in case of multiple items like in Email.
Namefield have spaces in between them or any other field?Namecolumn. I got the email part, how about Name column?|as the field separator for your data. Good luck.