On Mon, Feb 3, 2014 at 10:00 AM, Peter Stephenson wrote: > On Mon, 03 Feb 2014 18:36:00 +0100 > Roman Neuhauser wrote: > > having an array such as > > > > declare -a partitions; partitions=( > > /boot:boot:512:fat:boot,legacy_boot > > :swap:10240:swap > > /:root:-:btrfs > > ) > If you were to put a trailing colon on the partitions with no mount flags, you'd have the same number of colons in each array element, which might make some other things easier (as PWS mentioned). > for mountp name size fs flags in ...; do > Given the trailing colons to create empty flags fields for the lines that do not have flags, you can do for mountp name size fs flags in "${(@s.:.)${(j.:.)partitions}}" However, I'd still prefer Peter's nested loops. > for line in $partitions; do > for mountp name size fs flags in "${(@s.:.)line}"; do > print mountp=$mountp name=$name size=$size fs=$fs flags=$flags > done > done > Another option is while IFS=: read mountp name size fs flags; do # ... done <<<${(F)partitions} That should work even without the trailing colons, but could be tricky if you need standard input inside the loop body.