Jeff Blaine wrote:
> The following fails:
>     echo /some/place/foo.txt | basename

As Eric noted, basename requires an argument.

> This also fails:
>     find /somewhere -print | xargs basename

Why did that fail?  Are you also getting an error message from find?

You usually want to include the xargs -r option if you think it might
not have any input at all.

  find /somewhere -print | xargs -r basename

> This *does* work though, somehow, when the above does not:
>     echo /some/place/foo.txt | xargs basename

That will invoke basename with one argument.  Which is fine.

You can verify what xargs will do by calling echo first.

  find /somewhere -print | xargs echo basename

  echo /some/place/foo.txt | xargs echo basename

Bob

Reply via email to