[X-Unix] Script - works, but not where I need it to
William H. Magill
magill at mcgillsociety.org
Wed Jun 30 22:23:28 PDT 2004
On 30 Jun, 2004, at 21:08, Bert Knabe wrote:
> I have a shell script to copy all files added to a folder in the last
> 24 hours to another folder. It works, but only when invoked from my
> computer. When invoked on our Xserve, it gets the following error:
>
> [computer:/Users/Shared] admin% sh filecopy22.txt
> filecopy22.txt: /usr/bin/find: Argument list too long
>
> The script is just a line or two:
>
> find /Volumes/composing/\ \ \ Running\ Ads/* -mtime 1 -exec cp -p {}
> /Volumes/Online/\PDF\'S/In/ \;
Pretty standard problem with find (and ls) -- the argument list is the
number of files in the directory(s) "found". On the server it's
probably much larger than on your local machine.
You need to use xargs ... which normally you pipe into. (man xargs).
Haven't used it in ages, so off hand I forget the syntax when using it
with find ... I think it is to simply break the find before the -exec
command and pipe it into xargs ...
find ... -mtime 1 \; | xargs cp -p /Volumes/Online/\PDF\'S/In/
By the way -- if you plan on doing lots of stuff like this from the
command line, loose the apostrophe and make it simply "PDFs" or "PDF-s"
... ditto for spaces in file names -- use a dash or underscore. It
makes command line life much easier.
T.T.F.N.
William H. Magill
# Beige G3 - Rev A motherboard - 768 Meg
# Flat-panel iMac (2.1) 800MHz - Super Drive - 768 Meg
# PWS433a [Alpha 21164 Rev 7.2 (EV56)- 64 Meg]- Tru64 5.1a
# XP1000 [Alpha EV6]
magill at mcgillsociety.org
magill at acm.org
magill at mac.com
More information about the X-Unix
mailing list