I need to find all
.pem files on my system. Would the following do this?
sudo find / -type f -name *.pem
If not, how would I write a find command to find every file of the sort?
Server Fault is a question and answer site for system and network administrators. It only takes a minute to sign up.Sign up to join this community
find / will normally be very slow. Using
locate is much faster but somewhat imprecise because it doesn't support anything more complex than substring matching. A directory called
.pembroke will be found and returned by locate along with every file inside it.
A combination of
grep, however, has speed and precision. Conveniently, it also does not require
locate .pem | grep "\.pem$"
The downside? The database
locate uses is normally only updated once per day so any recent changes (additions, deletions, name changes, etc.) will not be found.