bugfindutils - Bugs: bug #19904, xargs produces different output...

 
 

bug #19904: xargs produces different output with similar "-d" parameter

Submitter:  None
Submitted:  Sat 19 May 2007 10:18:38 AM UTC
   
 
Category:  xargs Severity:  3 - Normal
Item Group:  Wrong result Status:  Invalid
Privacy:  Public Assigned to:  jay
Originator Name:  Filippo SAntovito Originator Email:  -email is unavailable-
Open/Closed:  Closed Release:  4.2.28
Fixed Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Sun 22 Jul 2007 02:12:28 PM UTC, comment #3: 

No response from submitter; closing.

James Youngman <jay>
Group administrator
Sat 19 May 2007 11:05:56 AM UTC, comment #2: 

I believe you have misunderstood how the -d option works.   If you use "xargs -d '<SPACE>'" then newline is not a separator.  The "extra" newline is simply the last character in the last argument.  

This example may make this clearer for you:

$ printf "foo bar\nbaz ugh quux\n"    | ./xargs  -n1 -d ' ' echo X
X foo
X bar
baz
X ugh
X quux

$ echo "foo bar" | tr -d '\n'  | ./xargs -n1  -d ' ' echo ZZZ
ZZZ foo
ZZZ bar

James Youngman <jay>
Group administrator
Sat 19 May 2007 10:27:53 AM UTC, comment #1: 

The point the submiter is making is that
xargs -d' '
executes the command one more time, with an empty string as arg. Shorter testcase:

ametzler@argenau:/tmp/findtest$ touch foo
ametzler@argenau:/tmp/findtest$ find . -name foo |xargs -d' '
./foo

ametzler@argenau:/tmp/findtest$ find . -name foo |xargs -n1
./foo
ametzler@argenau:/tmp/findtest$

Note the additinoal empty line.
cu andreas

Andreas Metzler <ametzler>
Sat 19 May 2007 10:18:38 AM UTC, original submission:  

$ mkdir temp; cd temp
$ for n in $(seq 0 9); do touch "file$n xxx.txt"; done;
$ find . -name "file[0-9]*" | xargs -d' ' -n1 -I X echo X
$ find . -name "file[0-9]*" | xargs -n1 echo
$ find . -name "file[0-9]*" | xargs -d' ' -n1 -I X echo X | wc -l
$ find . -name "file[0-9]*" | xargs -n1 echo | wc -l



Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by jay (Posted a comment)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2007-07-22 jay Open/ClosedOpen Closed
    2007-05-24 jay Summaryxargs produces different output with similar parameter xargs produces different output with similar "-d" parameter
    2007-05-19 jay StatusNone Invalid
        Assigned toNone jay
    2007-05-19 ametzler Carbon-CopyRemoved 20807 -

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code