coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [coreutils] basename/dirname can't handle stdin?


From: Bob Proulx
Subject: Re: [coreutils] basename/dirname can't handle stdin?
Date: Wed, 12 Jan 2011 13:09:00 -0700
User-agent: Mutt/1.5.20 (2009-06-14)

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

[Prev in Thread] Current Thread [Next in Thread]