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: Thu, 13 Jan 2011 17:55:56 -0700
User-agent: Mutt/1.5.20 (2009-06-14)

Jeff Blaine wrote:
> Bob Proulx wrote:
> > Why did that fail? ...
> 
> [jblaine@new-host src]$ find /home/jblaine -mtime -1 -print | xargs 
> /bin/basename
> /bin/basename: extra operand `/home/jblaine/.gconf/apps'
> Try `/bin/basename --help' for more information.

Ah... Yes, too many arguments.  In that case ask xargs to not provide
that many.

Give this a try:

  find . -type f -print0 | xargs -r0 -I{} basename {} .txt

And with dirname something like this:

  find a -type f -print0 | xargs -r0 -L1 dirname

BTW...  You shouldn't hard code paths such as /bin/basename.  On some
systems basename is in /bin and and on some in /usr/bin.  It is always
better to avoid hard coded paths, which create portability problems,
and instead locate programs from PATH.

Bob



reply via email to

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