Using "find" to search an entire system

Status
Not open for further replies.

anneranch

Active Member
Joined
Mar 16, 2019
Messages
223
Reaction score
43
Credits
2,078
[email protected]:~$ sudo find . -name "mdi.pro"
./Downloads/qt-everywhere-src-6.2.1/qtbase/examples/widgets/mainwindows/mdi/mdi.pro
./Qt/Examples/Qt-6.2.2/widgets/mainwindows/mdi/mdi.pro
[email protected]:~$

REALLY STUPID question:
The above searches ONLY current folder .
I need to search entire multi OS for LAST mdi.pro file used.

Help would be appreciated .

I'll be happy camper if I search RUNNING OS only.
 


f33dm3bits

Gold Member
Gold Supporter
Joined
Dec 11, 2019
Messages
5,916
Reaction score
4,408
Credits
43,483
[email protected]:~$ sudo find . -name "mdi.pro"
You can replace the the .(dot) with the path you want to search, for example / or /home and you only need to use sudo to search locations that your user doesn't have access to.
Code:
sudo find / -name "mdi.pro"
find /home/qw . -name "mdi.pro"
.(dot) means current folder
..(dot dot) means parent folder
~(tilde) means your homedir
 

JasKinasis

Well-Known Member
Joined
Apr 25, 2017
Messages
1,704
Reaction score
2,471
Credits
13,677
You can replace the the .(dot) with the path you want to search, for example / or /home and you only need to use sudo to search locations that your user doesn't have access to.
Code:
sudo find / -name "mdi.pro"
find /home/qw . -name "mdi.pro"
.(dot) means current folder
..(dot dot) means parent folder
~(tilde) means your homedir
Also, if you're searching the entire file-system, you might get a lot of error messages in your output.
For example, when find starts searching in places like /proc/ - which contains running processes. It may throw errors about being unable to stat, or open the files in there. This can be a problem even if you're running find as root.
So if searching from the root of the file-system, it's often worth redirecting any error messages to /dev/null, so you don't see them!
e.g.
Bash:
sudo find / -type f -name "mdi.pro" 2> /dev/null

There are ways to tell find to exclude certain directories - but I'm pretty lazy. Rather than keeping track of which directories find might have trouble accessing and then specifying to exclude those directories from the search - I simply leave it to iterate through them all from the file-systems root /. And redirect all error messages to the bit-bucket as per the previous example.

That way, I don't have to type a bunch of extra code to exclude a handful of directories, or sit through an endless stream of error messages! Ha ha!
Just a little tip!
 

Lord Boltar

Well-Known Member
Joined
Nov 24, 2020
Messages
2,211
Reaction score
1,616
Credits
16,331
I use Catfish to search for all things on the drop down on left side select File System - select the Gear on the right to included Hidden Files if you want the just type in what your looking for
catfish.png
 

captain-sensible

Well-Known Member
Joined
Jun 14, 2019
Messages
2,910
Reaction score
1,970
Credits
18,114
catfish new one to me ; just installed it on Arch , i will see how it compares to find


used find recently to check for duplicate images ; the way i did it was using a to take one image eg IMG_20160420_093807.jpg at one location and test to see if it existed at other i.e Toshiba for it at another. I knew that if there was a duplicate for that one image , then all the others would be as well . I used :

Code:
find  /run/media/andrew/"TOSHIBA EXT"   -name   IMG_20160420_093807.jpg   -print

it worked fine ,but did i need to use -print ?
 

Condobloke

Well-Known Member
Joined
Apr 30, 2017
Messages
6,086
Reaction score
5,081
Credits
38,407
catfish user here too.

simple & quick.
 

JasKinasis

Well-Known Member
Joined
Apr 25, 2017
Messages
1,704
Reaction score
2,471
Credits
13,677
catfish new one to me ; just installed it on Arch , i will see how it compares to find


used find recently to check for duplicate images ; the way i did it was using a to take one image eg IMG_20160420_093807.jpg at one location and test to see if it existed at other i.e Toshiba for it at another. I knew that if there was a duplicate for that one image , then all the others would be as well . I used :

Code:
find  /run/media/andrew/"TOSHIBA EXT"   -name   IMG_20160420_093807.jpg   -print

it worked fine ,but did i need to use -print ?
No, you didn't need to use -print, because -print is the default action!
 
OP
A

anneranch

Active Member
Joined
Mar 16, 2019
Messages
223
Reaction score
43
Credits
2,078
Thanks , with little hiccups - no progress indicator - it seems to work as advertised.

Addendum
Pretty impressive tool , even if it is "only" "find" wrapped in GUI.
Found little snag - search for "BT_*" finds
"ebt_xxxx".

But I did not RTFM, maybe I missed some option.
Same goes for "folders" - assuming it means transversing down
the tree, so far no go.

I feel it would be a good idea to "see the progreess" to make sure the search is going
correct direction.

And the "usual problem" - it takes forever to scan 3TB drive....
 
Last edited:
Status
Not open for further replies.
MALIBAL Linux Laptops

Linux Laptops Custom Built for You
MALIBAL is an innovative computer manufacturer that produces high-performance, custom laptops for Linux.

For more info, visit: https://www.malibal.com

Members online


Latest posts

Top