The -exec
option of find
wants pure executables, while alias
-es are a shell feature, meaning that they exist only when you are within a shell.
You can run any command within a shell by making -exec
run bash -c command
. However, for aliases to be accepted, the shell has to be run interactively.
You can trick the interactiveness by executing bash -ic sha256
, but since you put your alias definition in .bash_profile
you would also need to trick it as a “login shell” as well as an interactive one, because that file is only read by so-called “login shells”. That is, you should execute bash -lic sha256
. But that is slower and pollutes your sessions log a bit.
Therefore I would advise you to rather put your alias definition in .bashrc
file (just create it if don't have it yet), so that your alias can be used by a simpler bash -i
instead of bash -li
.
This would make your whole command like:
find ./ -iname *.doc -exec bash -ic 'sha256 "$1"' -- {} \;
If you really must keep your alias definition in .bash_profile
then make your command like:
find ./ -iname *.doc -exec bash -lic 'sha256 "$1"' -- {} \;