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,
- Clear Screen shortcut macOS Terminal
- What is macOS Ventura?
- [fix] How to Show file extensions on all files on Mac
- How to Find Where Mac Terminal App is Located?
- AutoSave button not working on Office on Mac (Word, Excel or Powerpoint)
- macOS say command text to speech using various voices and languages
- How to change Ping TTL value on macOS
- Open .bash_profile File in TextEdit using Terminal
- How to know the Safari Version on Mac
- How to Copy full Absolute Path of a File on Mac
- 13.0 MacOS Ventura release date
- Enable spell check in Sublime Text (macOS)
- How to Display Analog Clock on Mac Menu Bar
- How to turn off Location Services macOS Ventura 13
- How to Open VS Code on Mac
- Add Bookmark macOS Safari
- How to Fix cd: too many arguments Error in Terminal: A Step-by-Step Guide
- How to install wget on macOS
- Select Line Number TextEdit on Mac
- Strikethrough Text in Excel for Mac
- How to Enable or Disable Dark Mode on macOS Ventura 13
- How to hide or display Wifi icon in macOS Bug Sur Menu Bar
- How to install Yarn on Mac (macOS)
- How to fix command not found brew (bash, zsh) on macOS Terminal
- How to Schedule Mails in macOS Ventura
More Posts:
- [Solution] POI: Cannot get a NUMERIC value from a STRING cell - Java
- How To Change Mac Terminal Text Color - MacOS
- Get Current Local Date and Time using Java 8 DateTime API - Java
- Connect to 3270 host IBM Mainframe using Mac Terminal (c3270) - MacOS
- SharePoint List redirect user after submitting form NewForm.aspx - SharePoint
- How to change Ping TTL value on macOS - MacOS
- Mac Shortcut for Fullscreen mode for App Window - MacOS
- Get the total size and number of objects of a AWS S3 bucket and folders - AWS