In order to find a file on the Mac Terminal, you can make use of the find or mdfind command.
find – walk a file hierarchy
Syntax:
find <path-to-find> -name <name-of-file-to-find>
Example:
% find /Users/code2care/Desktop -name key.pem
Note: You might get pop-up alerts saying "Terminal would like to access your XXXX", which you need to allow to look for the file and you may see console logs saying Operation not permitted

mdfind command
mdfind – finds files matching a given query
Example:% mdfind -name key.pem
2022-10-31 23:37:51.443 mdfind[97925:2194875] [UserQueryParser] Loading keywords and predicates for locale "en_US"
2022-10-31 23:37:51.443 mdfind[97925:2194875] [UserQueryParser] Loading keywords and predicates for locale "en"
/Users/code2care/Desktop/key.pem
/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/site-packages/future/backports/test/ssl_key.pem
Note: The mdfind command makes use of the Spotlight database to provide search results, so it is faster compared to find command. As it does not have to do the scanning the whole file system for the query, but on the other side, its database may not be up-to-date as indexing is delayed so you may not find the file that may exist.
-
Facing issues? Have Questions? Post them here! I am happy to answer!
More Posts related to MacOS,
- How to Display Analog Clock on Mac Menu Bar
- Shutdown Mac Terminal Command
- How to know the Serial Number of MacBook on macOS Ventura 13.0
- macOS: Remove Desktop or Documents Folder from iCloud Drive Syncing
- [fix] How to Show file extensions on all files on Mac
- How to install Zoom Add-in to Outlook (Mac)
- How to turn off Stage Manager - macOS Ventura
- Fix - Xode - Internal logic error: Connection was invalidated
- How to do calculations in Mac Terminal
- How to delete a Page in Microsoft Word File on Mac (macOS)
- How to Refresh Mac Desktop
- How to install Java on macOS [Big Sur]
- How to Disable Mac Terminal Bell Sound
- Installing MongoDB on Linux/Unix/macOS/Ubuntu
- How to Uninstall Brew on Mac
- Find your macOS version
- Change TextEdit File Encoding
- AppleScript Example with TextEdit
- How to install homebrew (brew) on M1 Mac
- How to Find File and Directory Size in Mac Terminal
- How to open new tab in Sublime Text Editor [macOS]
- How to list all users in Mac Terminal
- Turn off Auto-Capitalization on macOS Ventura 13
- How to check Command Line Tools Version [Updated for Ventura]
- Change Current User Password using Mac Terminal Command
More Posts:
- How to enable disable SharePoint Developer Dashboard for tracing troubleshooting - SharePoint
- How to Compare Strings in Bash Script - Bash
- Error code - 7: There's a more permanent way to sign in to Microsoft Teams - Teams
- YAML Parser using Java Jackson Library Example - Java
- How to check the version of Python Modules - Python
- Java: LinkedList offer vs add methods - Java
- PHP Base64 encoding decoding a variable - PHP
- 🎃 Trending, Popular Halloween hashtags for year 2020 🎃 [Facebook, Twitter, Instagram, Snapchat] - Hashtags