>From: "Stewart C. Russell" <scruss at scruss.com> >David Ledger wrote: >>> You do have to be careful with xargs if you're processing a *lot* of >>> arguments. BSD xargs has a default argument limit of 5000 (hidden in the >>> '-n' para of the manual), so if you're calling xargs through sort (say), >>> the results may not be what you expect. >> >> That's not what it means. > >It might not be what it means, but it's what it does. > >On OS X: >$ perl -le 'for (1..5000) {print $_;}' | xargs echo | wc -l > 1 >$ perl -le 'for (1..5001) {print $_;}' | xargs echo | wc -l > 2 >So in effect, there's a default '-n 5000' in the xargs invocation, for >in the second case 'echo' is being called twice. It's different on other >unices, f'rinstance with Gnu xargs on Cygwin: That's what _I_ said. _You_ originally said that there's a '5000 argument limit in xargs'. You obviously understand it better than your original email implied, and what I wrote obviously didn't manage to say what I meant to you. There is no limit in xargs as such. The limit is in other parts of the OS. xargs was written as a way round that limit. It knows (conservatively, possibly inaccurately) what that limit is and works accordingly. It allows control over the value it uses as a limit in case you know better. If there were no OS limit, xargs would not exist, but, being as its there, its a handy alternative to other techniques. > >If you're worried about efficiency over expediency, you shouldn't be >using shell. Shell gives you programmer speed. If you need something it's better to have it as a shell script rather than to not have it at all, which is usually the alternative. It's probably my assembler programming background, but I always try to make my shell scripts as efficient as possible. Shell scripts are inefficient in cpu, and a poorly written script multiply so. All the more reason to script efficiently. Some boxes I've worked on could probably work as well with one less cpu if the monitoring and housekeeping scripts were better written. David -- David Ledger - Freelance Unix Sysadmin in the UK. Chair of HPUX SysAdmin SIG of hpUG technical user group (www.hpug.org.uk) david.ledger at ivdcs.co.uk www.ivdcs.co.uk