InfoHeap
Tech tutorials, tips, tools and more
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. How to search files by name in Mac Finder
  2. Svn log of all files in a directory
  3. Mac command line utility open – some handy tips for better productivity
  4. Csslint – quick command-line tutorial and how to use it for pre-deployment sanity check
  5. Rsync – using dryrun to list changed files
  6. Linux – find files containing specific text
  7. Mac Finder – how to search system hidden files
  8. Linux du – find disk usage of directories or files
Share this article: share on facebook share on linkedin tweet this submit to reddit
Posted in Tutorials | Tagged Mac, Mac Command Line, Tutorials

Follow InfoHeap

facebook
twitter
googleplus
  • Browse site
  • Article Topics
  • Article archives
  • Recent Articles
  • Contact Us
  • Omoney
Popular Topics: Android Development | AngularJS | Apache | AWS and EC2 | Bash shell scripting | Chrome developer tools | 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

Copyright © 2023 InfoHeap.

Powered by WordPress