find: -exec vs xargs (aka Why does "find | xargs basename" break?)
Because basename
wants just one parameter... not LOTS of. And xargs
creates a lot of parameters.
To solve your real problem (only list the filenames):
find . -name '*.deb' -printf "%f\n"
Which prints just the 'basename' (man find):
%f File's name with any leading directories
removed (only the last element).
Try this:
find . -name '*.deb' | xargs -n1 basename
basename only accepts a single argument. Using -exec
works properly because each {}
is replaced by the current filename being processed, and the command is run once per matched file, instead of trying to send all of the arguments to basename in one go.