Find: Difference between revisions

From Psygen Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 5: Line 5:
<code>find /home myfile.txt</code> This will look in the /home folder for myfile.txt (if you leave out the location, find will look in the directory you are currently in.)
<code>find /home myfile.txt</code> This will look in the /home folder for myfile.txt (if you leave out the location, find will look in the directory you are currently in.)


== By Name ==


By default, find is case-sensitive. The above example will not find MYFILE.TXT. If you want the search to be case insensitive:
By default, find is case-sensitive. The above example will not find MYFILE.TXT. The <code> -iname </code> flag tells find to ignore case.
 
If you want the search to be case insensitive:


<code>find -iname myfile.txt</code>
<code>find -iname myfile.txt</code>
Line 17: Line 20:




== By Type ==
<code>find -type f -name "*.txt"</code> This will find all the files whose name ends in .txt in the current directory.
The <code> -type f </code> flag tells find to look for files ( <code> -type d </code> will tell find to look for directories.)




Line 23: Line 31:
<ol>
<ol>
   <li>[http://man.he.net/?topic=find&section=all find man page]</li>
   <li>[http://man.he.net/?topic=find&section=all find man page]</li>
  <li>[http://www.tecmint.com/35-practical-examples-of-linux-find-command/ Tecmint find Examples]</li>
</ol>
</ol>

Revision as of 17:54, 23 December 2016

Find is used to search the directory system for files.

find location options search pattern

find /home myfile.txt This will look in the /home folder for myfile.txt (if you leave out the location, find will look in the directory you are currently in.)

By Name

By default, find is case-sensitive. The above example will not find MYFILE.TXT. The -iname flag tells find to ignore case.

If you want the search to be case insensitive:

find -iname myfile.txt

The above will find all of the following: myfile.txt MYFILE.TXT MyFile.txt (etc...)


By Type

find -type f -name "*.txt" This will find all the files whose name ends in .txt in the current directory.

The -type f flag tells find to look for files ( -type d will tell find to look for directories.)


References

  1. find man page
  2. Tecmint find Examples