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

 
 

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

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

Add a New Comment (Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

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

No response from submitter; closing.

James Youngman <jay>
Project AdministratorIn charge of this item.
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>
Project AdministratorIn charge of this item.
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)
  •  

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    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.5