If I have document and want to iterate the second column of the document into an array, would there be a simple way to do this. At present I am trying by using:
cat file.txt | awk -F'\t' '{print $2}' | sort -u
This lists all the unique items in the second column to standard out.
The question is ...how do I now add these items to an array, considering some of these items have whitespace.
I have been trying to declare an array
arr=()
and then tried
${arr}<<cat file.txt | awk -F'\t' '{print $2}' | sort -u