How to find files with find tool in system path ($PATH)? Or alternatively, How to specify starting-point directory for find as an expression?
1
vote
2
answers
115
views
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?
Asked by Anton Samokat
(289 rep)
Apr 11, 2024, 02:19 PM
Last activity: Apr 11, 2024, 08:07 PM
Last activity: Apr 11, 2024, 08:07 PM