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
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 $7? It will fail if the path contain more spaces, right?awk solution is a non-solution, as you are only processing the directory name, not the names of the files contained under the directory. While the IFS-based solution works, it only works for file names that don't contain new lines (which are rare, but legal).
find pwd?