For example, I want to find all symlinks that reference to particular binary in all directories that belong to system $PATH. This can be successfully achieved with manual specification of all directories:
sudo find ~/bin /home/samokat/.local/bin /home/samokat/bin /usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin /snap/bin -lname /opt/openoffice4/program/soffice
But when I'm trying to use command with $PATH expansion:
sudo find `echo $PATH | tr ':' ' '` -lname /opt/openoffice4/program/soffice
I get error and result:
find: ‘~/bin’: No such file or directory
/usr/bin/soffice.link-to-openoffice-bak
echo $PATH | tr ':' ' '
outputs correct path:
~/bin /home/samokat/.local/bin /home/samokat/bin /usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin /snap/bin
The following also are not working:
sudo find `echo $PATH | tr ':' ' ' | xargs` -lname /opt/openoffice4/program/soffice
sudo find { `echo $PATH | tr ':' ' ' | xargs` } -lname /opt/openoffice4/program/soffice
sudo find eval "echo $PATH | tr ':' ' ' | xargs" -lname /opt/openoffice4/program/soffice
echo $PATH | tr ':' ' ' | xargs | sudo find -lname /opt/openoffice4/program/soffice # runs some long computation
How to pass starting point
directories as calculable parameter to find
? Does this possible?
~
in yourPATH
.PATH
is an environment variable for all applications. It is processed by C library functions likeexecvp
andpopen
. Whereas~
is POSIX shell syntax, for tilde expansion. The operating system doesn't understand~
, only the shell does.