InfoHeap
Tech
Navigation
  • Home
  • Tutorials
    • CSS tutorials & examples
    • CSS properties
    • Javascript cookbook
    • Linux/Unix Command Line
    • Mac
    • PHP
      • PHP functions online
      • PHP regex
    • WordPress
  • Online Tools
    • Text utilities
    • Online Lint Tools
search

Mac Command Line tutorials

  • Bulk convert jpeg files to png using sips on mac
  • Custom terminal tab title and ssh on mac
  • How to convert text to speech on Mac using command line utility say
  • How to join multiple pdf files on Mac
  • How to use qpdf to add/remove password from pdf on mac
  • Install redis on Mac
  • Mac - find which process is listening on a port
  • Mac - hide and unhide a file or directory
  • Mac - open a terminal from a folder
  • Mac - print java home on command line
  • Mac - search files on command line using mdfind
  • Mac command line convert svg to png
  • Mac command line utility open - some handy tips for better productivity
  • Mac terminal - how to close shell on exit
  • mac pkgutil - quick start guide
 
  • Home
  • > Tutorials
  • > Mac
  • > Mac Command Line

Mac – search files on command line using mdfind

By admin on Dec 8, 2015

Mac spotlight and finder are great way to find files on Mac. But Mac also has command line utility mdfind (utility to query meta data) which can be used to find files on Mac. It uses the same meta data which is used by spotlight search but can also find system files. Here are some use cases.
mac-mdfind-example

Create sample test files for mdfind tutorial

  1. Create file1234.txt in /opt/tmp/dir1 with following content
    file1234
    
  2. Create file4567.txt in /opt/tmp/dir2 with following content
    file1234
    

mdfind – find files (file name or content) anywhere on Mac

$ mdfind file1234
/opt/tmp/tmp3/dir2/file5678.txt
/opt/tmp/tmp3/dir1/file1234.txt

mdfind – find files (file name or content) in a dir

$ mdfind -onlyin dir1 file1234
/opt/tmp/tmp3/dir1/file1234.txt

mdfind – find files (file name only) anywhere on Mac

$ mdfind -name file1234
/opt/tmp/tmp3/dir1/file1234.txt

Suggested posts:

  1. Iterate over specific file extension in a dir in shell script
  2. PHP – convert array to associative array
  3. Svn – how to make file executable on Linux
  4. Mysql – how to copy a table
  5. How to run a program as administrator on windows 10
  6. PhantomJS – find all fonts-families on a web page
  7. Jenkins how to clone a project
  8. CSS clearfix – clear float automatically using ::after
Share this article: share on facebook share on linkedin tweet this submit to reddit
Posted in Tutorials | Tagged Mac, Mac Command Line, Tutorials
  • Browse content
  • Article Topics
  • Article archives
  • Contact Us
Popular Topics: Android Development | AngularJS | Apache | AWS and EC2 | Bash shell scripting | Chrome developer tools | Company results | CSS | CSS cookbook | CSS properties | CSS Pseudo Classes | CSS selectors | CSS3 | CSS3 flexbox | Devops | Git | HTML | HTML5 | Java | Javascript | Javascript cookbook | Javascript DOM | jQuery | Kubernetes | Linux | Linux/Unix Command Line | Mac | Mac Command Line | Mysql | Networking | Node.js | Online Tools | PHP | PHP cookbook | PHP Regex | Python | Python array | Python cookbook | SEO | Site Performance | SSH | Ubuntu Linux | Web Development | Webmaster | Wordpress | Wordpress customization | Wordpress How To | Wordpress Mysql Queries | InfoHeap Money

Copyright © 2025 InfoHeap.

Powered by WordPress