[arch-general] BASH no longer does 'for i in $(ls); do ls $i; done'??

dave reisner d at falconindy.com
Tue May 18 19:07:57 EDT 2010


Using ls for something like this is never a good idea, as Daenyth's link
repeatedly points out. Use bash's globbing to get the job done.

for i in *; do
  foo $i
done

Also unlike ls, this won't fail because of aliases or white spaces, either.
It just works(tm).

d

On Tue, May 18, 2010 at 5:40 PM, Samuel Martín Moro <faust64 at gmail.com>wrote:

> you may want to try
> for i in $(`which ls` -d .) ; do `which ls` $(`which pwd`)/$i; done
> it does work here
>
> Samuel Martín Moro
> {EPITECH.} tek4
> CamTrace S.A.S
>
> "Nobody wants to say how this works.
>  Maybe nobody knows ..."
>                     Xorg.conf(5)
>
>
> On Tue, May 18, 2010 at 10:58 PM, Aaron Griffin <aaronmgriffin at gmail.com
> >wrote:
>
> > On Tue, May 18, 2010 at 3:47 PM, Sergey Manucharian
> > <ingeniware at gmail.com> wrote:
> > > Excerpts from Linas's message of Tue, 18 May 2010 22:31 +0200:
> > >
> > >> David C. Rankin wrote:
> > >> > Guys,
> > >> >
> > >> >     I'm usually quite good at one-liners, but my simple ones no
> > >> > longer work in Arch. Same cli works fine in suse. What have I
> > >> > messed up? To wit:
> > >> >
> > >> >
> > >> >     What could keep the simple cli from working on Arch? I know
> > >> > this stuff worked before updates this morning... What should I look
> > >> > at?
> > >> Bash was updated from 4.1.5(2) to 4.1.7(2).
> > >> I can't reproduce it, though.
> > >
> > > I cannot reproduce it either and suspect that your "ls" under $() is
> > > not the real ls, but an alias. I've played with some, and they indeed
> > > produce bad output.
> >
> > If this is the case, replace "ls" with "/bin/ls" in the above and try
> again
> >
>


More information about the arch-general mailing list