I am having CSVhave a space-delimited file as below:
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 it to have an array through themparse 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])
and so based on column.
My code is:
column=1
for arrayname in Pool Library; do
mapfile -t "$arrayname" < <(awk "NR > 1 {print \$$column}" file.txt)
((column++))
done
But itsit's failing in case of multiple items like in Email.
I am novice so please help me with complete codeEmail.