On 1 June 2011 20:30, Mike Williams <dmikewilliams(a)gmail.com> wrote:
On Wed, Jun 1, 2011 at 3:18 PM, JD <jd1008(a)gmail.com> wrote:
>
> On 06/01/11 12:05, Patrick O'Callaghan wrote:
> > No, each filename counts as one argument, even if it has
spaces in it.
> > The problem arises when you *use* the argument. The above should read:
> >
> > for i in *; do
> > [ -f "$i"]&& echo "$i" is a file
> > done
> > (the quotes are optional in the echo case obviously).
> The quotes are not optional.
I think he meant that the quotes are optional for the echo $i - which is
correct.
Not entirely:
$ echo a b
a b
Personally I avoid spaces in filenames and usually use a perl one
liner
to substitute an underscore for spaces when I don't have to keep the
original name for someone else.
Yes, in general hours of pain here, especially if you work with people
who do lots of shell scripting and another group of people who use
Windows lots.
zsh works without any quotes, the first example works fine for files
with spaces in the names with zsh.
Might have to look into that, I keep meaning to check out zsh properly.
--
imalone