On 05/27/2010 04:47 AM, Jon Clausen wrote:
Indeed... however:
Now I *have* tested, and somewhat surprisingly (to me at least) filenames with whitespace are not a problem:
<snip>
so there :)
/jon
Hmm... Old dog, new trick! That's pretty cool: 09:55 alchemy:~/tmp> ( myarray=(*); for ((i=0;i<${#myarray[@]};i++)); do printf "myarray[%2d]: %s\n" ${i} "${myarray[${i}]}"; done ) myarray[ 0]: 2010 Narrative Update.txt myarray[ 1]: 80 myarray[ 2]: 90dcf370cbde.tif myarray[ 3]: Abstract-DarkGlow.emerald.zip <snip> What I am uncomfortable with is the spaces issue, despite having proven it to myself, but as long as globbing holds, then there should be no reason this wouldn't be as safe as 'for i in *; do ...xyz...; done. In fact, it is probably preferred over my usual: SARRAY=( $(ls $SEARCHDIR) ), though I can't lay my hand on a rule telling me which is preferred. With my usual method, setting IFS to newline is definitely required. What i like about (*) is that globbing handles all the spaces for you when loading the array. However, you would still need IFS set to newline (or religious quoting) for any subsequent processing of names with spaces later on in the script. New trick added to toolbox :p (as far as the quoting/IFS issue, try the above cli without quotes around "${myarray[${i}]}" ) -- David C. Rankin, J.D.,P.E. Rankin Law Firm, PLLC 510 Ochiltree Street Nacogdoches, Texas 75961 Telephone: (936) 715-9333 Facsimile: (936) 715-9339 www.rankinlawfirm.com -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org