By default, BASH's for loop uses the whitespace character as separator. This can be changed by setting the variable "IFS" to something else, as found on the web.
This is actually true, but there's a caveat!
Example:
Code: Select all
function test
{
IFS="
"
FILES=`find . -name *.txt`
for file in $FILES; do
echo $file
done
}
Because the code is indented. Eliminate the spaces on the left side and it works:
Code: Select all
function test
{
IFS="
"
FILES=`find . -name *.txt`
for file in $FILES; do
echo $file
done
}