Paul L. Snyder on 19 May 2005 18:13:32 -0000 |
Quoting "Michael C. Toren" <mct@toren.net>: > On Thu, May 19, 2005 at 01:32:10PM -0400, Jeff Abrahamson wrote: > > The variable array is space separated (so not a bash array). I want > > bash to index through it like it does with command-line args and let > > me refer to each term in sequence. > > How about: > > foo=([0]="zero" [1]="one" [2]="two" [3]="three") [...] > for i in "${foo[@]}"; do > echo $i > done I usually use zsh, so I had to fire up bash to test this, and the below does work. bash performs word splitting on unquoted parameters. Combine with arthmetic expansion: foo="bar baz womble" c=0 for e in $foo; do echo "$c is $e"; c=$(($c+1)); done pls ___________________________________________________________________________ Philadelphia Linux Users Group -- http://www.phillylinux.org Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce General Discussion -- http://lists.phillylinux.org/mailman/listinfo/plug
|
|