Using the “find” command with real world examples

When you’re on a mac/bsd/*nix system you will likely have access to the “find” command which is extremely useful in helping you to “find” a file. This can be particularly handy in situations where you aren’t familiar with the layout of directories on a system and need to find a config file or whatever.

  • This command will search the ENTIRE filesystem for the filename you specify, you will almost certainly need to run this with sudo as there are a lot of directories which you do not have permissions to normally: find / -name hard_to_find_file.txt
  • This is the same as the above, except it searches the directory you are currently executing from: find . -name hard_to_find_file.txt
  • This one just searches your user’s home directory: find ~ -name hard_to_find_file.txt
  • You can also search for just files of a certain extension: find ~ -type f -name *.wav
  • This command will return any file with the string “key” in it’s filename: find / -name key





Leave a Reply

Your email address will not be published. Required fields are marked *

  −  three  =  2