{"id":1189,"date":"2011-11-30T09:42:00","date_gmt":"2011-11-30T07:42:00","guid":{"rendered":"http:\/\/raftaman.net\/?p=1189"},"modified":"2021-05-15T11:46:39","modified_gmt":"2021-05-15T09:46:39","slug":"how-to-find-multiple-patterns-with-gnu-findutils","status":"publish","type":"post","link":"https:\/\/possiblelossofprecision.net\/?p=1189","title":{"rendered":"How to find multiple patterns with GNU findutils"},"content":{"rendered":"<p>Actually, searching for multiple patterns should be a trivial task. Find provides a <code>-o<\/code>  operator (and many <a href=\"http:\/\/www.gnu.org\/software\/findutils\/manual\/html_mono\/find.html#Combining-Primaries-With-Operators\">others<\/a>) that lets you combine multiple expressions.<\/p>\n<p>A simple Example: You want to find all files in the current directory whose filename extension are either <code>.c<\/code> or <code>.h<\/code><\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n$ find . \\( -name &quot;*.c&quot; -o -name &quot;*.h&quot; \\) -print\r\n<\/pre>\n<p>This is not limited to the <code>-name<\/code> test but can be combined with any other test (like <code>-perm<\/code>, <code>-size<\/code>, <code>-type<\/code>, etc.)<\/p>\n<p><strong>But Careful!<\/strong> You need to quote patterns that contain metacharacters (such as * in the example above). Singe quotes work as well as double quotes. The braces surrounding the expression have to be escaped, too. And <strong>watch those spaces<\/strong> right before and after the braces, they&#8217;re essential.<\/p>\n<p>See also <a href=\"http:\/\/linux.die.net\/man\/1\/find\">find manpage<\/a>, <a href=\"http:\/\/www.gnu.org\/software\/findutils\/manual\/html_mono\/find.html\">GNU find documentation<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Actually, searching for multiple patterns should be a trivial task. Find provides a -o operator (and many others) that lets you combine multiple expressions. A simple Example: You want to find all files in the current directory whose filename extension are either .c or .h $ find . \\( -name &quot;*.c&quot; -o -name &quot;*.h&quot; \\) -print This is not limited&#8230; <a href=\"https:\/\/possiblelossofprecision.net\/?p=1189\">Read more &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[28],"class_list":["post-1189","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-bash"],"_links":{"self":[{"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=\/wp\/v2\/posts\/1189","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1189"}],"version-history":[{"count":13,"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=\/wp\/v2\/posts\/1189\/revisions"}],"predecessor-version":[{"id":2669,"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=\/wp\/v2\/posts\/1189\/revisions\/2669"}],"wp:attachment":[{"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1189"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1189"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1189"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}