Linux Find and/or Locate Files/Directories Primer Tutorial

Linux Find and/or Locate Files/Directories Primer Tutorial

Linux Find and/or Locate Files/Directories Primer Tutorial

Linux (or Unix) servers have two really useful commands which help the user find files and/or directories … locate and find. Doubt there are many people out there who have not mislaid a computer file at some time or other. The GUI options are there, such as Windows Explorer and Mac Finder, but you tend to think, with these, of the one area or folder to search (mind you both are capable of better), whereas you often face the dilemma of having no idea where the file is. The GUIs can help here, but find, for myself, that I always jump to the command line for this, with Windows command line DIR C: [filespec] /s or the Linux/Unix commands for today’s tutorial … locate and find.

So why confuse things with two choices? Well, locate is fast, once set up, because it sets up its own “database” of previous knowledge, and so can pluck out whatever you want really fast from then on, once you use a “sudo” command to set up locate for future use.

The strength of the Linux/Unix find command are its switches like “-type ?” to define what type of file to find, and the way you can use “exec” in a piped scenario, to add more functionality.

So some words about the syntax (and for this, found Linux by Steve Oualline and Eric Foster-Johnson (pp 72-73) an excellent source) where you can hover or click for further information:

  • locate gimp | more -y 13
  • find / -name “*gimp*” -type f -print 2> /dev/null | more -y 13
  • find $HOME/Documents -name “*.htm*” -type f -exec fgrep body {} /dev/null ;

So today we see some actions to find and/or locate files/directories with this tutorial.

If this was interesting you may be interested in this too.

This entry was posted in eLearning, Operating System, Tutorials and tagged , , , , . Bookmark the permalink.

36 Responses to Linux Find and/or Locate Files/Directories Primer Tutorial

Leave a Reply

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