FG

find: -exec vs xargs (aka Why does "find | xargs basename" break?)

Fresh3 days ago
Mar 15, 202622193 views
Confidence Score0%
0%

Problem

I was trying to find all files of a certain type spread out in subdirectories, and for my purposes I only needed the filename. I tried stripping out the path component via , but it did't work with : I get the same thing (exactly the same error) with either of these variations: This, on the other ha…

Error Output

$ find . -name '*.deb' -print | xargs basename 
basename: extra operand `./pool/main/a/aalib/libaa1_1.4p5-37+b1_i386.deb'
Try `basename --help' for m…

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix for: find: -exec vs xargs (aka Why does "find | xargs basename" break?)

Low Risk

Because wants just one parameter... not LOTS of. And creates a lot of parameters. To solve your real problem (only list the filenames): Which prints just the 'basename' (man find):

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment