I have this code
for i in $(find pwd)
do
    echo $i
done
the problem is if the file name contains spaces, it prints on a separate line
how can I list all of the files in some directory including files that contains spaces
I have this code
for i in $(find pwd)
do
    echo $i
done
the problem is if the file name contains spaces, it prints on a separate line
how can I list all of the files in some directory including files that contains spaces
 
    
    I would use while read for this.  
find . | while read i; do echo $i; done;
Edit:
Alternatively, you could just do ls -a1
 
    
    This would have the intended effect of your example:
find /path/to/somewhere
That is, no need to wrap a for loop around it.
But I'm guessing you want something more than just echoing. Perhaps call a script for each file? You can do that with:
find /path/to/somewhere -exec path/to/script.sh {} \;
where {} will be replaced for each filename found.
 
    
    here is the solution
IFS=$'\n'
    for i in $(pwd)
    do
        echo $i
    done
