>
> I have 2 files containing spaces in the filename.
>
> a 1 1.txt
> b 2 2.txt
>
> The follow bash script would produce the following output:
>
> $ for i in $(find); do echo “$i”; done
Lots of things to consider for files with special characters and/or spaces.
Consider:
find . -print0
combined with
xargs -0
Consider:
using filters to process the output of find into what you ware wanting to do
Consider:
using read to process line by line output (albeit slowly)
There are LOTS of ways to look at the problem. Without seeing more of the
code, it’s hard to determine the best solution.
You must deal with filenames by using quotations around them, else it will appear in a bash file to be more than one augment, possibly treated as multiple file names. I have run into the very same problem in scripts I have written which require the name of a file to be provided. Without the quotes, filenames with spaces are dealt with as multiple augments though such behavior is not totally consistent. Use the quotes in your program and all will be well and there is no extra charge to use them.