Difference between revisions of "Locate"

From Freephile Wiki
Jump to navigation Jump to search
(Undo revision 4899 because it was just a test by Freephile (talk))
Line 1: Line 1:
 
[[File:Locate.jpg|thumb|right|Locate your files in a snap]]
 
[[File:Locate.jpg|thumb|right|Locate your files in a snap]]
  
[[wp::Locate (Unix)]] is a fantastic utility in Linux that finds files on your 1 TB hard drive in just seconds.  It does this because each night it indexes everything on your disk.  It's like having your own little Google for your filesystem.  Which brings us to the "command-line-fu" tip of the day: if you are looking for a directory, use the built-in regular expression matching switch (-r).  In my case, I was trying to find where I had copies or backups of my 'phase3' directory.
+
[[wp::Locate (Unix)]] is a fantastic utility in Linux that finds files on your 1 TB hard drive in just seconds.  It does this because each night it indexes everything on your disk.  It's like having your own little Google for your filesystem.  Which brings us to the "command-line-fu" tip of the day: if you are looking for a directory, use the built-in regular expression matching switch (-r).   
 +
 
 +
So for example, I was trying to find where I had copies or backups of my "'''phase3'''" directory. Here is an invocation of locate using the dollar sign to match only results that end with phase3 (after a slash).  This command will NOT match all the files ''in'' those phase3 directories like a normal locate would.
 +
 
 +
Note: Because the dollar sign has special significance to the shell, we enclose the function argument in single quotes to pass it literally to the function and the shell won't 'see' it.
 +
 
 
<source lang="bash">
 
<source lang="bash">
 
locate -r '/phase3$'
 
locate -r '/phase3$'
 
</source>
 
</source>

Revision as of 15:46, 4 April 2013

Locate your files in a snap

Locate (Unix) is a fantastic utility in Linux that finds files on your 1 TB hard drive in just seconds. It does this because each night it indexes everything on your disk. It's like having your own little Google for your filesystem. Which brings us to the "command-line-fu" tip of the day: if you are looking for a directory, use the built-in regular expression matching switch (-r).

So for example, I was trying to find where I had copies or backups of my "phase3" directory. Here is an invocation of locate using the dollar sign to match only results that end with phase3 (after a slash). This command will NOT match all the files in those phase3 directories like a normal locate would.

Note: Because the dollar sign has special significance to the shell, we enclose the function argument in single quotes to pass it literally to the function and the shell won't 'see' it.

locate -r '/phase3$'