From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Joerg Bruehe Newsgroups: gmane.os.tru64.managers Subject: "xargs" generating lines shorter than ARG_MAX Date: Wed, 26 Jun 2002 17:24:04 +0200 Organization: SQL Datenbanksysteme GmbH Sender: tru64-unix-managers-owner@ornl.gov Message-ID: <3D19DC94.18949619@sql.de> NNTP-Posting-Host: localhost.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: main.gmane.org 1025106272 11371 127.0.0.1 (26 Jun 2002 15:44:32 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Wed, 26 Jun 2002 15:44:32 +0000 (UTC) Return-path: Original-Received: from sws1.ctd.ornl.gov ([160.91.20.101]) by main.gmane.org with smtp (Exim 3.33 #1 (Debian)) id 17NEy7-0002xI-00 for ; Wed, 26 Jun 2002 17:44:32 +0200 Original-Received: (qmail 22974 invoked by uid 5); 26 Jun 2002 15:24:37 -0000 Original-Followup-To: poster Precedence: bulk Original-Received: (qmail 22966 invoked from network); 26 Jun 2002 15:24:37 -0000 Original-Received: from unknown (HELO emroute3.ornl.gov) (134.167.3.110) by 0 with SMTP; 26 Jun 2002 15:24:37 -0000 Original-Received: from emroute3.ornl.gov (localhost [127.0.0.1]) by emroute3.ornl.gov (PMDF V6.1-1 #39060) with ESMTP id <0GYB005WPK50O1@emroute3.ornl.gov> for tru64-unix-managers@sws1.ctd.ornl.gov (ORCPT tru64-unix-managers@ornl.gov) ; Wed, 26 Jun 2002 11:24:37 -0400 (EDT) Original-Received: from server8a.software-ag.de (server8a.software-ag.de [193.26.193.47]) by emroute3.ornl.gov (PMDF V6.1-1 #39060) with ESMTP id <0GYB0093CK4FRR@emroute3.ornl.gov> for tru64-unix-managers@sws1.ctd.ornl.gov (ORCPT tru64-unix-managers@ornl.gov) ; Wed, 26 Jun 2002 11:24:17 -0400 (EDT) Original-Received: from sql.de by server8a.software-ag.de; (8.11.6/8.9.3) id g5QFO4P17107; Wed, 26 Jun 2002 17:24:04 +0200 Original-To: Tru64-Admin Liste X-Mailer: Mozilla 4.7 [en] (WinNT; I) X-Accept-Language: en Xref: main.gmane.org gmane.os.tru64.managers:704 X-Report-Spam: http://spam.gmane.org/gmane.os.tru64.managers:704 Dear admins, I encounter difficulties with the "xargs" command: In a directory tree, I want to find out which files were modified last. So I enter: find . -type f -mtime -3 -print | xargs ls -ltrd | more However, I get a "ls" output with date/time increasing from "Jun 24" to "Jun26" (= today) in the first 68 lines, then jumping back to "Jun 24" and again increasing to "Jun26" in the next 70 lines, the same happening in the next 97 lines, ... - in total my 551 output lines consist of 7 (seven) blocks with ascending date/time only within each block. My only explanation is that "ls" is called 7 times, each time with a partial list of files. I would happily accept that behaviour if the list of files were too long for a single call, but: a) find . -type f -mtime -3 -print | wc yields "551 551 13005" which is far less than "ARG_MAX" (38912), and my environment occupies only 180 bytes ("env | wc" yields "10 10 180"), and b) ls -ltrd `find . -type f -mtime -3 -print` works perfect (and yields 551 lines), so the file list really does fit into a single call. To test that further, I wrote me a simple script "tmpsh" that does echo $* | wc and called find . -type f -mtime -3 -print | xargs tmpsh which gave me seven lines, the first six with 2011 .. 2021 byte argument size and the last one with 923. So it seems that "xargs" does limit the generated line to about 2 kB (and not the ridiculous 470 byte given in the man page). Using the "-s" parameter to "xargs", I could reduce the length but not increase it, but got no error message (on large values). Do you have any idea why the command line generated by "xargs" is so much shorter than what is obviously possible, or any hint how I could increase the line length towards "ARG_MAX"? My environment: The OS is version 4.0 D (878) upgraded fron 4.0 B (564), "xargs" is version 4.2.8.2 ("which xargs" -> "/usr/bin/xargs"), the shell is the system-supplied "/usr/bin/csh" ("sh.c": 4.2.37.3), with the Bourne-compatible "/usr/bin/sh" the effect is the same. Regards and TIA, Joerg Bruehe -- Joerg Bruehe, SQL Datenbanksysteme GmbH, Berlin, Germany (speaking only for himself) mailto: joerg@sql.de