On Fri, 15 Feb 2008, David C. Rankin wrote:-
Stumbling around, it seems if you include AFS='\n' it will keep the loop from breaking on spaces by specifying that it only break on newlines and not spaces. So filenames with spaces (all my wife's digital pictures are) this is the only thing I have found to work without extensive character and replacing spaces with '_':
AFS='\n' for i $list; do
^ You're missing an 'in' there.
Telling the loop not to break on spaces with AFS seems to work like a charm. Are there any better ways? echo "i = $1" done
Since you're only using $list to hold the list of file names that are used in the for loop, don't use $list. Assuming you assigned $list using: list="$(ls *.jpg)" this would have the same effect: for i in *.jpg do echo "i = ${i}" done Alternatively, if you must use $list, you can use the following instead: echo "${list}" | \ while read i do echo "i = ${i}" done One last tip: try getting into the habit of wrapping {} around variable names. It comes in handy for figuring out what are variables when you use echo, and it's good at preventing typos from messing them up. E.g. text="some line of text" echo "$text is used for testing" gets you: some line of test is used for testing However, missing out a space: text="some line of text" echo "$textis used for testing" gets you: used for testing whereas putting {} around text: text="some line of text" echo "${text}is used for testing" gets you: some line of textis used for testing While this may not seem important, it helps when debugging, and is required if you're going to use arrays. 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