how to handle spaces in filenames

I'm trying to do something like that:
for $filename in `ls -1`
do
some_command $filename
done

but it doesn't work properly for file names with spaces, for...in splits at spaces. Anyway around?

file name should be in double quotes

Try this -

for $filename in `ls -1`
do
some_command "$filename"
done

Try this :

ls | \
while IFS= read filename
do
   some_command "$filename"
done

Jean-Pierre.

No, it doesn't work.
aigles, I'm actually looking for a way to do this in a for loop, if possible. Thanks anyway.

Removes the $ from the variable name in the for statement:

for filename in `ls -1`
do
   some_command $filename
done

Replaces the ls command by the * pattern:

for filename in *
do
   some_command $filename
done

Jean-Pierre.