In the following command I would like to know why $0
was evaluated to the file found by find
and not the echo
command.
$ find . -type f -perm -u=x -exec bash -c '
/bin/echo $0 is the name of the file' {} \;
I know that if I had used double quotes, $0
would equal -bash
and using single quotes delays the expansion, but why doesn't it expand to /bin/echo
since that is the called command (which normally would be $0
)?
$0
to expand tobash
, but notecho
. Do you expectrm "$0"
to attempt to removerm
? See also http://unix.stackexchange.com/q/140779 and https://unix.stackexchange.com/q/152391 – Stéphane Chazelas May 12 '15 at 14:42