Store values from a file into an array variable in Shell

view full story

http://www.unix.com – Dear All, I have been trying to do a simple task of extracting 2 fields from the file (3 rows) and store it in an array variable. I tried with: #! /bin/bash ch=`cut -f10 tmp.txt` counter=0 for p in $pid do c=${ch[$counter]} echo "$c ..$counter" counter=$((counter+1)) done The filed 10 has 3 values: 14,19,6 in tmp.txt file. When I execute, I am getting: 14 19 6 ..0 ..1 ..2 but I would like to have: 14 ..0 19 ..1 6 ..2 Could you please help me to fix this? Thanks in advance, Ezhil (HowTos)