[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: how to convert 100 bmp files to jpeg?



Star King of the Grape Trees <thestar@fussycoder.id.au> said on Mon, 16 Jan 2006 10:47:03 +1100:
> Ron Johnson wrote:
> 
> >On Mon, 2006-01-16 at 08:40 +1100, Tim Connors wrote:
> >  
> >
> >><snip>
> >>
> >>Why on earth would you want to put ls in backticks?  I wonder who
> >>originated this rather redundant and fragile (what happens when a
> >>filename has any form of whitespace?) construct? 
> >>    
> >>
> That would be me.

Nope -- heaps of people have done this before you.  Did you pick this
technique up from someone else?

It'd be nice if the technique would kindly stop propogating :)

> >If you're dealing with so many files that the bash "glob buffer"
> >fills up, `ls *.bmp` can work around that.

I don't think there is a fixed limit glob buffer.  Are you sure you
are not confusing this with the amount of space bash is allowed to
allocate for arguments for spawned commands -- a kernel limit?

So saying:
for a in * ; do
   blah "$a"
done
has no limit, whereas
blah2 *
does have a limit (of about 20K characters, IIRC).

(hmmm, maybe more on the 2.6 kernel -- I can't seem to generate that
dreaded "Argument list too long" message except by doing something
stupid like:   ls -lA /var/spool/news/message.id/*/*   )

> And imho, much easier than dealing with xargs and find -exec whatnot ;
> Also, if spaces are a problem, fancy quotes can deal with that:
> for f in `ls *.bmp`; do echo "$f"; done <-- Note I have NOT tested this.

Nope.

#mkdir tmp
#cd tmp
#for i in `seq 1 10000` ; do touch "blah $i" ; done
#for f in `ls *`; do ls -lA "$f"; done
ls: blah: No such file or directory
ls: 1: No such file or directory
ls: blah: No such file or directory
ls: 10: No such file or directory
ls: blah: No such file or directory
ls: 100: No such file or directory
ls: blah: No such file or directory
ls: 1000: No such file or directory
ls: blah: No such file or directory
....

Because each space output by the backticks causes the for loop to plop
the next bit into a new loop.



Reply to: