Tim Connors wrote:
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 :)
Well, I believe I got this from some "advanced" bash guide, or a man
page or two.
<snip>
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?
All I know is that it works for me.
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/*/* )
I have run into this message many times - but I manage a fileserver that
has several million files.
Naturally, I try to really avoid any sort of manipulation on this
server, but sometimes there is no way it can be avoided. (From memory, I
had to use find, rather than ls)
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.
Interesting.
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]