On Sat, Jan 04, 2003 at 09:51:21PM -0500, Fraser Campbell wrote: > On January 4, 2003 09:20 pm, the fabulous Gerald V. Livingston II wrote: > > > Thank you. Took a couple of tries to get the syntax correct but I > > ended up with this: > > > > if [ `ls *.jpg 2>/dev/null|wc -l` -gt 0 ] > > > > then for i in *.jpg; do mmv "$i" `date +%s`-$a.jpg; a=a+1; done > > > > fi > > If there were thousands of jpgs you'll probably still get a "too many > arguments" error with that for loop. I usually do something like this:
Nope, The for is "internal" to the shell. It will not suffer from the "too many arguments" problem. Whereas, the "ls" you suggest is external and WILL have that problem! > > ls *.jpg | while read i; do > mv "$i" `date +%s`-$a.jpg; a=a+1 > done [ I created a directory whith too many files and then: ] sh-2.05$ ls * | while read i ; do > echo $i > done sh: /bin/ls: Argument list too long sh-2.05$ [ whereas: ] sh-2.05$ for i in * ; do echo $i; done .... alksdjfklasjljkdasjkladsjklasdjlkasjkldfljksljkjklassdkljfljkdsfjlsalkfj999 h-2.05$ ("ls" IS internal on some shells, but apparently not in mine, or maybe not when running non-interactively, but then again, I DID do this interactively... ) Roger. -- ** [EMAIL PROTECTED] ** http://www.BitWizard.nl/ ** +31-15-2600998 ** *-- BitWizard writes Linux device drivers for any device you may have! --* * The Worlds Ecosystem is a stable system. Stable systems may experience * * excursions from the stable situation. We are currently in such an * * excursion: The stable situation does not include humans. *************** -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]