LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to find files without mounted shares? (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-find-files-without-mounted-shares-4175581360/)

sysmicuser 06-03-2016 09:10 AM

How to find files without mounted shares?
 
Answer is this:
[root@agent2 /]# find / -fstype local -type d -iname collectd


However it is annoying and it does go to /media which has mounted external hard drive. It not only shows "No such file or directory" errors but moreover its time consuming and not required when I know for sure collectd has to has files and folders on root file system.

Anyway, I am looking for learned people to shed some more light.

MadeInGermany 06-03-2016 09:24 AM

Does find / -fstype local ... really work?
I would rather go for find / -xdev ...
And perhaps your system has "locate" or "mlocate" installed and working?
Then it is just
Code:

locate collectd

sysmicuser 06-03-2016 09:43 AM

Actually locate work but it doesn't help me.For reason I want to find collectd.cgi script. I can go to my tutorial and find its location but that doesn't make me independent researcher.

xdev gives this syntax error.

[root@agent2 /]# find / -xdev local -type d -iname collectd
find: paths must precede expression: local
Usage: find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec] [path...] [expression]
[root@agent2 /]#

sysmicuser 06-03-2016 09:45 AM

Output of locate

[root@agent2 /]# locate collectd
/etc/selinux/targeted/modules/active/modules/collectd.pp
/opt/puppetlabs/puppet/share/augeas/lenses/dist/collectd.aug
/opt/puppetlabs/puppet/share/augeas/lenses/dist/tests/test_collectd.aug
/usr/share/augeas/lenses/dist/collectd.aug
/usr/share/selinux/devel/include/services/collectd.if
/usr/share/selinux/targeted/collectd.pp.bz2
[root@agent2 /]#

MadeInGermany 06-03-2016 09:46 AM

You must replace
Code:

-fstype local
by
Code:

-xdev

sysmicuser 06-03-2016 10:06 AM

Thanks MadeInGermany ! You got it right.

I want to take it further, with directories found for each directory I want to find file with extension "*.cgi"

[root@agent2 /]# find / -xdev -type d -iname collectd
/var/lib/collectd
/usr/lib64/collectd
/usr/include/collectd
/usr/share/collectd
[root@agent2 /]# find / -xdev -type d -iname collectd|xargs find -type f -iname "*.cgi"
find: paths must precede expression: /var/lib/collectd
Usage: find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec] [path...] [expression]
[root@agent2 /]#


This would be good as we can use practically for anything and everything.

MadeInGermany 06-03-2016 10:50 AM

find needs the start directories first, while xargs by default puts them last. You can use -i or -I option for xargs
Code:

find / -xdev -type d -iname collectd | xargs -i find {} -type f -iname "*.cgi"
but an ls on the directories is simpler
Code:

find / -xdev -type d -iname collectd -exec ls {} \; | grep '.*\.cgi$'

sysmicuser 06-03-2016 10:58 AM

Many Thanks mate ! It does help. I am raising another thread for not having examples directory after collectd installation


All times are GMT -5. The time now is 10:40 AM.