[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug #39824] Add suggestion 'ls | tr \\n \\0 | xargs -0 command' to xarg

From: Edward J. Huff
Subject: [bug #39824] Add suggestion 'ls | tr \\n \\0 | xargs -0 command' to xargs man page
Date: Tue, 20 Aug 2013 18:08:45 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:23.0) Gecko/20100101 Firefox/23.0

Follow-up Comment #3, bug #39824 (project findutils):

I agree that the proposed paragraph is not adequate, and have written more
extensive revisions to the *xargs* man page, to be submitted immediately.

I will not be using *|tr \n \0|xargs -0* anymore because *|xargs -d\n* takes
fewer keystrokes.  I wasn't aware of that option until I started working on a
revision to the man page.

In reply to
Solving the problem for whitespace-but-not-newlines only solves part of the
problem. Examples in manpages should, as far as possible, not come with
It is very easy to create filenames containing blanks, tabs, quote marks, or
backslashes using desktop GUI applications.  Those applications refuse to
create filenames containing newlines.  Thus, failure to handle newlines is not
so much of a pitfall for desktop users.

Since there are many useful tools for massaging file names that lack *--null*
options (such as *grep* and *sed*), and since GUI users (who will be reading
the man page to learn to use *xargs*) still need to use shell commands to deal
with many filenames at once, none of which contain newlines, the manpage
should not begin by suggesting that the default options are useful.

Lack of a -0 option isn't a problem in the case you suggest (since the program
being invoked, xargs, has -0).
(Actually, the program is *ls | grep*).  Now *grep* does have a 
*-Z* option, but that is for the case when *grep* is reporting a list of files
which contain an instance of the pattern.  It would be nice if *grep* had an
option to treat newlines like other whitespace and nulls like newlines, but it

Well, ok, if I know that filenames do not contain  1 characters, I can write
*find ... -print0 | tr \n\0 \1\n | grep ... | tr \1\n \n\0 | xargs -0*, but
this is a lot of keystrokes when I happen to know the filenames do not contain
find . -maxdepth 1 -mindepth 1 -regex regexp -exec stat {} + 

requires more keystrokes and new users have no chance of coming up with it
from memory.  Efficiency is just not a problem on modern single-user systems.


Reply to this item at:


  Message sent via/by Savannah

reply via email to

[Prev in Thread] Current Thread [Next in Thread]