On Thu, 14 Feb 2008, Randall R Schulz wrote:-
That's what quotes do. They create a single string. The ones where LIST is defined are required because a shell variable (that is not an array) can have only a single value and ordinary parsing would break the output of ls at each occurrence of a (run of) whitespace characters.
No it doesn't. Try this on a command line: LIST=$(ls -1) ; echo "\"${LIST}\"" This will perform an ls in the PWD, and assign the results to LIST. The echo statement then displays the contents of $LIST and wraps it in quotes so you can see the start and end of the variables contents. You should see something like this: davjam@adder:~/temp> ls 200802052337 200802061302 count.all count.txt 200802052337.sorted 200802061302.sorted count.sorted extract.sh davjam@adder:~/temp> LIST=$(ls -1) ; echo "\"${LIST}\"" "200802052337 200802052337.sorted 200802061302 200802061302.sorted count.all count.sorted count.txt extract.sh"
The one in the "for" loop, where any number of words is allowed, causes there to be only one, holding the entire output from the "ls" invocation.
Correct.
I personally like to use array variables in BASH scripting. They're very hand because they can be spread across multiple lines _without_ using backslashes and by putting a single value on each line, you can easily comment out certain values by commenting the line that contains them within the array initialization.
The problem there is that, in this case, how do you populate the array?
for number in "${numbers[@]}"; do echo $number done
Didn't know about this method of extracting the contents of an array. Noted for later use.
for number in "${numbers[*]}"; do echo $number done
Didn't know this one either, so this is also noted for later use. Regards, David Bolt -- Team Acorn: http://www.distributed.net/ OGR-P2 @ ~100Mnodes RC5-72 @ ~15Mkeys SUSE 10.1 32bit | openSUSE 10.2 32bit | openSUSE 10.3 32bit | openSUSE 11.0a1 SUSE 10.1 64bit | openSUSE 10.2 64bit | openSUSE 10.3 64bit RISC OS 3.6 | TOS 4.02 | openSUSE 10.3 PPC | RISC OS 3.11 -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org