bug-coreutils
[Top][All Lists]
Advanced

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

Re: unexpected result on basename/dirname


From: Bob Proulx
Subject: Re: unexpected result on basename/dirname
Date: Wed, 17 Feb 2010 19:20:52 -0700
User-agent: Mutt/1.5.18 (2008-05-17)

C de-Avillez wrote:
> I cannot explain the following difference between running a 'find -exec
> basename {}', and a 'find -exec echo $(basename {})', and the same for
> dirname.

The shell is processing $(...) on the command line before passing the
result as an argument to the command.  You can see this using echo.

> address@hidden:~/Téléchargements$ find . -type f -exec echo 
> $(/usr/local/bin/basename {}) \;

Try this:

  $ echo find . -type f -exec echo $(/usr/local/bin/basename {}) \;
  find . -type f -exec echo {} ;

As you can see the result of "$(basename {})" is "{}".  This is passed
to 'find'.  Then 'find' is executing based upon the arguments in the
resulting invocation.

Bob




reply via email to

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