shell –array in while loop

shell –array in while loop

0

first I have a file which have some gene_IDs: ZM011,ZD012,ZF033,…..
Then I want to convert these gene id to different numbers.
Like ZM011 -> 1, ZD012 -> 2,….
I try use shell script like this:

   i=1
   cat ids.txt | while read id; do arr[$id]=$i let i++; done
   echo ${#arr[@]}

but the output is 0

I don’t know how to do this


shell

• 35 views

Read more here: Source link