shell — while

shell — while

1

when I do something like this,I got a question:

yi@yi:~$ cat ids.txt
CDS
chromosome
exon
five_prime_UTR
gene
mRNA
scaffold
three_prime_UTR

# this way has a result
yi@yi:~$ while read line; do arr1[++i]=$line;done < ids.txt
yi@yi:~$ echo ${arr1[@]}
CDS chromosome exon five_prime_UTR gene mRNA scaffold three_prime_UTR

# but this one -- nothing!!!
yi@yi:~$ cat ids.txt | while read line;do arr2[++i]=$line;done
yi@yi:~$ echo ${arr2[@]}

yi@yi:~$

why!!!!


shell

• 23 views

updated 1 hour ago by

&starf;

3.8k

written 2 hours ago by

0

1 hour ago by


Sam

&starf;

3.8k


Login
before adding your answer.

Traffic: 1802 users visited in the last hour

Read more here: Source link