tru64-unix-managers (formerly alpha-osf-managers) (1994-2012)
 help / color / mirror / Atom feed
From: Joerg Bruehe <joerg@sql.de>
Subject: SUMMARY: "xargs" generating lines shorter than ARG_MAX
Date: Thu, 27 Jun 2002 11:35:31 +0200	[thread overview]
Message-ID: <3D1ADC63.8BDDEA0C@sql.de> (raw)
In-Reply-To: 3D19DC94.18949619@sql.de

Dear admins,

as usual on this list, I got several replies to my question - 
thank you to all those (details further down).

The short summary: 
   The Tru64 "xargs" builds command lines no longer than 2 kB, 
   that applies to versions 4 as well as 5, and that behaviour 
   can not be changed (by the user / admin).


Now the details:

   I had wanted to get a list of recently modified files (from 
   several levels in a directory hierarchy) by the command 
      find . -type f -mtime -3 -print | xargs ls -ltrd | more 
   but got my 551 files (size of "find" output: 13005 byte) 
   in seven sorted groups, due to seven separate calls of "ls".

   Getting seven separate calls destroys the fuction I wanted, 
   because I do not get a date/time order of _all_ files.

   I has asked why "xargs" generates these short lines when 
   the system supports longer ones (proof: 
      ls -ltrd `find . -type f -mtime -3 -print` 
   works perfect) and whether I had a chance to change that.


Fred Cassirer (of HP) proposed to let "find" produce the "ls" 
output immediately, without "xargs", by 
   find . -type f -mtime 3 -ls 
However, in that way I do not get any date/time sorting.

Mike ? ( mcaplin@miami.edu ) proposed to use "echo" 
to see the command lines generated by "xargs" 
(good idea, I could thus verify my theory of the seven calls) 
and also pointed at the "-i" option for explicit placement of 
the "xargs" input in the generated command line 
(does not change the size, so the problem remains).

Lucien Hercaud used "truss" to trace "xargs", he found that it 
reads the input pipe in 8 kB portions (the "PIPSIZ" value) and 
   "does output gathering of the args in blocks of -a bit- less 
   than 2k (2048).  ...  This behaviour is the same for version 
   4.0 and 5.1A of Tru64." 
(So the problem will remain the same in the next version.)

Dr Thomas Blinn comments 
   "I can't tell you why there is such a small limit..  
   I'm sure there is a historical reason for it." 
(with no change in version 5) and also proposes to perform the 
task by writing a shell, C, or perl script / program.

Dr Tim Cutts comments "xargs is being conservative" and proposes 
GNU xargs whose limit is 20 k (or a Perl script, which does not 
have any such limit). If I run into this situation more often, 
I will probably get and install the GNU version.


Let me repeat my personal point of view: 
Given the fact that Tru64 supports much longer command lines 
- in the OS (see '/usr/sys/include/sys/syslimits.h': 
  the ARG_MAX limit for "exec" calls is 38 kB = 38912) and  
- in shells (the single command line 
      ls -ltrd `find . -type f -mtime -3 -print` 
  does work, where this "find" yields 13,005 bytes), 
I am disappointed that "xargs" does impose such a low limit 
(for which I see no technical reason). 
I would rather accept / expect a shell with a line length limit 
(due to it keeping history, providing command line edit, doing 
variable substitution, getting interactive input or files where 
the editor has a restriction, ...) than this one in "xargs".


Regards and thanks for all answers,
Joerg Bruehe

-- 
Joerg Bruehe, SQL Datenbanksysteme GmbH, Berlin, Germany
     (speaking only for himself)
mailto: joerg@sql.de


      reply	other threads:[~2002-06-27  9:35 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-06-26 15:24 "xargs" generating lines shorter than ARG_MAX Joerg Bruehe
2002-06-27  9:35 ` Joerg Bruehe [this message]
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox