I have two Ubuntu installations:
A: 14.04.3 LTS (GNU/Linux 3.13.0-77-generic x86_64)
B: 14.04.2 LTS (GNU/Linux 3.13.0-61-generic x86_64)
I'm running the following command:
find . -name "nosuch.file" -print0 | xargs -0 ls
(the real command is more complex, but I managed to narrow it down to this).
There is no file nosuch.file in the current directory or subdirectories.
On server A the command produces empty output as I expected.
On server B the command produces the listing of the current directory (where I run the command).
On both servers running just find . -name "nosuch.file" -print0 produces empty output.
On both servers the same version of find, xargs and ls is installed:
$ find --version
find (GNU findutils) 4.4.2
Copyright (C) 2007 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Eric B. Decker, James Youngman, and Kevin Dalley.
Built using GNU gnulib version e5573b1bad88bfabcda181b9e0125fb0c52b7d3b
Features enabled: D_TYPE O_NOFOLLOW(enabled) LEAF_OPTIMISATION FTS() CBO(level=0)
$ xargs --version
xargs (GNU findutils) 4.4.2
Copyright (C) 2007 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Eric B. Decker, James Youngman, and Kevin Dalley.
Built using GNU gnulib version e5573b1bad88bfabcda181b9e0125fb0c52b7d3b
$ ls --version
ls (GNU coreutils) 8.21
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Richard M. Stallman and David MacKenzie.
Why would the command behave differently? What can I do to achieve consistent behaviour as on server A (empty output for no found files)?
xargshave an alias defined which includes the-r/--no-run-if-emptyoption? If so, that would result in no output.xargstype -a xargson both servers as there's a chance that a function or a script with that name that acts as a wrapper for the actualxargscommand.xargs -rpresents the desired behaviour.