<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://kb.rvmgroup.it/index.php?action=history&amp;feed=atom&amp;title=Tutorial_su_Find</id>
	<title>Tutorial su Find - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://kb.rvmgroup.it/index.php?action=history&amp;feed=atom&amp;title=Tutorial_su_Find"/>
	<link rel="alternate" type="text/html" href="https://kb.rvmgroup.it/index.php?title=Tutorial_su_Find&amp;action=history"/>
	<updated>2026-05-05T21:33:50Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.44.2</generator>
	<entry>
		<id>https://kb.rvmgroup.it/index.php?title=Tutorial_su_Find&amp;diff=4783&amp;oldid=prev</id>
		<title>Gabriele.vivinetto at 16:31, 24 July 2006</title>
		<link rel="alternate" type="text/html" href="https://kb.rvmgroup.it/index.php?title=Tutorial_su_Find&amp;diff=4783&amp;oldid=prev"/>
		<updated>2006-07-24T16:31:41Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Preso da: [http://www.linux.com/article.pl?sid=06/06/28/1541237 Linux.com | CLI Magic: Searching with find:]&lt;br /&gt;
==&amp;#039;&amp;#039;&amp;#039;CLI Magic: Searching with find&amp;#039;&amp;#039;&amp;#039;==&lt;br /&gt;
&lt;br /&gt;
Monday July 10, 2006 (08:01 AM GMT)&lt;br /&gt;
&lt;br /&gt;
By: [http://www.samspublishing.com/bookstore/product.asp?isbn=067232847X&amp;amp;rl=1 Paul Hudson and Andrew Hudson]&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;find&amp;lt;/code&amp;gt; command is one of the darkest and least understood areas of Linux, but it is also one of the most powerful. The biggest problem with &amp;lt;code&amp;gt;find&amp;lt;/code&amp;gt; is that it has more options than most people can remember -- it truly is capable of doing most things you could want.&lt;br /&gt;
&lt;br /&gt;
{| cellpadding=&amp;quot;10&amp;quot; align=&amp;quot;right&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;This article is excerpted from the newly published book &amp;#039;&amp;#039; [http://service.bfast.com/bfast/click?bfmid=2181&amp;amp;sourceid=39391960&amp;amp;isbn=067232847X Red Hat Fedora 5 Unleashed] &amp;#039;&amp;#039;. Excerpt provided by Sams Publishing.&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
Admittedly, the &amp;lt;code&amp;gt;find&amp;lt;/code&amp;gt; command does not help itself by using X-style parameters. The Unix standard is &amp;lt;code&amp;gt;-c&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-s&amp;lt;/code&amp;gt;, and so on, whereas the GNU standard is &amp;lt;code&amp;gt;--dosomething&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;--mooby&amp;lt;/code&amp;gt;, and so forth. X-style parameters merge the two by having words preceded by only one dash. The most basic usage is this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;find -name &amp;quot;*.txt&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
That query searches the current directory and all subdirectories for files that end in &amp;lt;code&amp;gt;.txt&amp;lt;/code&amp;gt;. The previous search finds files ending in &amp;lt;code&amp;gt;.txt&amp;lt;/code&amp;gt; but not &amp;lt;code&amp;gt;.TXT&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.Txt&amp;lt;/code&amp;gt;, or other case variations. To search without case sensitivity, use &amp;lt;code&amp;gt;-iname&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;-name&amp;lt;/code&amp;gt;. You can optionally specify where the search should start before the &amp;lt;code&amp;gt;-name&amp;lt;/code&amp;gt; parameter, like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;find /home -name &amp;quot;*.txt&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Another useful test is &amp;lt;code&amp;gt;-size&amp;lt;/code&amp;gt;, which lets you specify how big the files should be to match. You can specify your size in kilobytes and optionally also use &amp;lt;code&amp;gt;+&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;-&amp;lt;/code&amp;gt; to specify greater than or less than. For example:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;code&amp;gt;find /home -name &amp;quot;*.txt&amp;quot; -size 100k&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;code&amp;gt;find /home -name &amp;quot;*.txt&amp;quot; -size +100k&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;code&amp;gt;find /home -name &amp;quot;*.txt&amp;quot; -size -100k&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first brings up files of exactly 100KB, the second only files greater than 100KB, and the last only files less than 100KB.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;-user&amp;lt;/code&amp;gt; option enables you to specify the user that owns the files you are looking for. So, to search for all files in &amp;lt;code&amp;gt;/home&amp;lt;/code&amp;gt; that end with &amp;lt;code&amp;gt;.txt&amp;lt;/code&amp;gt;, are under 100KB, and are owned by user &amp;lt;code&amp;gt;paul&amp;lt;/code&amp;gt;, you would use this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;find /home -name &amp;quot;*.txt&amp;quot; -size -100k -user paul&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can flip any of the conditions by specifying &amp;lt;code&amp;gt;-not&amp;lt;/code&amp;gt; before them. For example, you can add a &amp;lt;code&amp;gt;-not&amp;lt;/code&amp;gt; before &amp;lt;code&amp;gt;-user paul&amp;lt;/code&amp;gt; to find matching files owned by everyone &amp;#039;&amp;#039;but&amp;#039;&amp;#039; &amp;lt;code&amp;gt;paul&amp;lt;/code&amp;gt;&amp;lt;nowiki&amp;gt;:&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;find /home -name &amp;quot;*.txt&amp;quot; -size -100k -not -user paul&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can add as many &amp;lt;code&amp;gt;-not&amp;lt;/code&amp;gt; parameters as you need, even using &amp;lt;code&amp;gt;-not -not&amp;lt;/code&amp;gt; to cancel each other out! (Yes, that is pointless.) Keep in mind, though, that &amp;lt;code&amp;gt;-not -size -100k&amp;lt;/code&amp;gt; is essentially equivalent to &amp;lt;code&amp;gt;-size +100k&amp;lt;/code&amp;gt;, with the exception that the former will match files of exactly 100KB whereas the latter will not.&lt;br /&gt;
&lt;br /&gt;
You can use &amp;lt;code&amp;gt;-perm&amp;lt;/code&amp;gt; to specify which permissions a file should have for it to be matched. This is tricky, so read carefully. The permissions are specified in the same way as with the &amp;lt;code&amp;gt;chmod&amp;lt;/code&amp;gt; command: &amp;lt;code&amp;gt;u&amp;lt;/code&amp;gt; for user, &amp;lt;code&amp;gt;g&amp;lt;/code&amp;gt; for group, &amp;lt;code&amp;gt;o&amp;lt;/code&amp;gt; for others, &amp;lt;code&amp;gt;r&amp;lt;/code&amp;gt; for read, &amp;lt;code&amp;gt;w&amp;lt;/code&amp;gt; for write, and &amp;lt;code&amp;gt;x&amp;lt;/code&amp;gt; for execute. However, before you give the permissions, you need to specify a plus, a minus, or a blank space. If you specify neither a plus nor a minus, the files must exactly match the mode you give. If you specify &amp;lt;code&amp;gt;-&amp;lt;/code&amp;gt;, the files must match all the modes you specify. If you specify &amp;lt;code&amp;gt;+&amp;lt;/code&amp;gt;, the files must match any the modes you specify. Confused yet?&lt;br /&gt;
&lt;br /&gt;
The confusion can be cleared up with some examples. This next command finds all files that have permission &amp;lt;code&amp;gt;o=r&amp;lt;/code&amp;gt; (readable for other users). Notice that if you remove the &amp;lt;code&amp;gt;-name&amp;lt;/code&amp;gt; parameter, it is equivalent to &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; because all filenames are matched.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;find /home -perm -o=r&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Any files that have &amp;lt;code&amp;gt;o=r&amp;lt;/code&amp;gt; set are returned from that query. Those files also might have &amp;lt;code&amp;gt;u=rw&amp;lt;/code&amp;gt; and other permissions, but as long as they have &amp;lt;code&amp;gt;o=r&amp;lt;/code&amp;gt;, they will match. This next query matches all files that have &amp;lt;code&amp;gt;o=rw&amp;lt;/code&amp;gt; set:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;find /home -perm -o=rw&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
However, that query does not match files that are &amp;lt;code&amp;gt;o=r&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;o=w&amp;lt;/code&amp;gt;. To be matched, a file must be readable &amp;#039;&amp;#039;and&amp;#039;&amp;#039; writeable by other users. If you want to match readable &amp;#039;&amp;#039;or&amp;#039;&amp;#039; writeable (or both), you need to use &amp;lt;code&amp;gt;+&amp;lt;/code&amp;gt;, like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;find /home -perm +o=rw&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Similarly, this next query matches files that are only readable by user, group, and others:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;find /home -perm -ugo=r&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Whereas this query matches files as long as they are readable by the user, or by the group, or by others, or by any combination of the three:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;find /home -perm +ugo=r&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you use neither &amp;lt;code&amp;gt;+&amp;lt;/code&amp;gt; nor &amp;lt;code&amp;gt;-&amp;lt;/code&amp;gt;, you are specifying the exact permissions to search for. For example, the next query searches for files that are readable by user, group, and others but not writeable or executable by anyone:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;find /home -perm ugo=r&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can be as specific as you need to be with the permissions. For example, this query finds all files that are readable for the user, group, and others and writeable by the user:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;find /home -perm ugo=r,u=w&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To find files that are not readable by others, use the &amp;lt;code&amp;gt;-not&amp;lt;/code&amp;gt; condition, like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;find /home -not -perm +o=r&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, on to the most advanced aspect of the find command: the &amp;lt;code&amp;gt;-exec&amp;lt;/code&amp;gt; parameter. This enables you to execute an external program each time a match is made, passing in the name of the matched file wherever you want it. This has very specific syntax: Your command and its parameters should follow immediately after &amp;lt;code&amp;gt;-exec&amp;lt;/code&amp;gt;, terminated by &amp;lt;code&amp;gt;\;&amp;lt;/code&amp;gt;. You can insert the filename match at any point using &amp;lt;code&amp;gt;{}&amp;lt;/code&amp;gt; (an opening and a closing brace side by side).&lt;br /&gt;
&lt;br /&gt;
So, you can match all text files on the entire system (that is, searching recursively from &amp;lt;code&amp;gt;/&amp;lt;/code&amp;gt; rather than from &amp;lt;code&amp;gt;/home&amp;lt;/code&amp;gt; as in our previous examples) over 10KB, owned by &amp;lt;code&amp;gt;paul&amp;lt;/code&amp;gt;, that are not readable by other users, and then use &amp;lt;code&amp;gt;chmod&amp;lt;/code&amp;gt; to enable reading, like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;find / -name &amp;quot;*.txt&amp;quot; -size +10k -user paul -not -perm +o=r -exec chmod o+r {} \;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When you type your own &amp;lt;code&amp;gt;-exec&amp;lt;/code&amp;gt; parameters, be sure to include a space before &amp;lt;code&amp;gt;\;&amp;lt;/code&amp;gt;. Otherwise, you might see an error such as &amp;lt;code&amp;gt;missing argument to ´-exec&amp;#039;&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Do you see now why some people think the &amp;lt;code&amp;gt;find&amp;lt;/code&amp;gt; command is scary? Many people learn just enough about &amp;lt;code&amp;gt;find&amp;lt;/code&amp;gt; to be able to use it in a very basic way, but hopefully you will see how much it can do if you give it a chance.&lt;br /&gt;
&lt;br /&gt;
===&amp;#039;&amp;#039;&amp;#039;Related Links&amp;#039;&amp;#039;&amp;#039;===&lt;br /&gt;
&lt;br /&gt;
 · [http://service.bfast.com/bfast/click?bfmid=2181&amp;amp;sourceid=39391960&amp;amp;isbn=067232847X Red Hat Fedora 5 Unleashed]&amp;lt;br /&amp;gt; · &amp;#039;&amp;#039;&amp;#039;[http://ostg.pricegrabber.com/mrdr.php?mode=ostg_linux_Tools_&amp;amp;_Utilities&amp;amp;url=http://ostg.pricegrabber.com/search_gen_top.php/topcat_search=1/form_keyword=Tools &amp;amp; Utilities Best deals: Tools &amp;amp; Utilities ]&amp;#039;&amp;#039;&amp;#039;&amp;lt;br /&amp;gt; · [http://www.linux.com/search.pl?tid=47 More Tools &amp;amp; Utilities stories]&amp;lt;br /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Gabriele.vivinetto</name></author>
	</entry>
</feed>