Home
| Calendar
| Mail Lists
| List Archives
| Desktop SIG
| Hardware Hacking SIG
Wiki | Flickr | PicasaWeb | Video | Maps & Directions | Installfests | Keysignings Linux Cafe | Meeting Notes | Linux Links | Bling | About BLU |
Hi Eric, > i'm trying to take a column in a text file and put it into an array. I think you're creating the array wrong: > -bash-3.2$ head test.csv > catname1.dat,,catname2.dat,,catname3.dat, > foo.txt,5,bar.txt,2,me.txt,1 > foo1.txt,10,bar1.txt,4,me1.txt,1 > foo2.txt,15,bar2.txt,5,me2.txt,2 > foo3.txt,20,bar3.txt,65,me3.txt,1 > foo4.txt,25,bar4.txt,4,me4.txt,2 > -bash-3.2$ files=`gawk -F, '{printf $1 " "}' test.csv` #column of values > -bash-3.2$ declare -a list_files=$files > -bash-3.2$ unset list_files[0] #delete first var in array > -bash-3.2$ echo $list_files $ head test.csv catname1.dat,,catname2.dat,,catname3.dat, foo.txt,5,bar.txt,2,me.txt,1 foo1.txt,10,bar1.txt,4,me1.txt,1 foo2.txt,15,bar2.txt,5,me2.txt,2 foo3.txt,20,bar3.txt,65,me3.txt,1 foo4.txt,25,bar4.txt,4,me4.txt,2 $ files=`awk -F, '{printf $1" "}' test.csv` $ echo $files catname1.dat foo.txt foo1.txt foo2.txt foo3.txt foo4.txt instead: $ files=(`awk -F, '{printf $1" "}' test.csv`) $ echo $files catname1.dat $ echo ${files[@]} catname1.dat foo.txt foo1.txt foo2.txt foo3.txt foo4.txt -ben -- do i contradict myself? very well then, i contradict myself, (i am large, i contain multitudes.) <walt whitman>
BLU is a member of BostonUserGroups | |
We also thank MIT for the use of their facilities. |