{"id":3309,"date":"2009-06-07T10:26:20","date_gmt":"2009-06-07T01:26:20","guid":{"rendered":"https:\/\/www.pistolfly.com\/weblog\/?p=3309"},"modified":"2018-04-01T20:54:08","modified_gmt":"2018-04-01T11:54:08","slug":"delete-or-grep-the-results-of-find","status":"publish","type":"post","link":"https:\/\/www.pistolfly.com\/weblog\/en\/2009\/06\/delete-or-grep-the-results-of-find.html","title":{"rendered":"Delete or grep the results of find"},"content":{"rendered":"<pre class=\"command-line\">-exec command {} \\;\r\n<\/pre>\n<ul>\n<li>Execute <em>command<\/em> after find. To pass results of find use {}.<\/li>\n<li>You must put a blank before \"\\;\". If a blank is missing, an error occurrs like below.\n<pre class=\"command-line\">$ find . -name *~ -exec rm {}\\;\r\nfind: missing argument to `-exec'\r\n<\/pre>\n<pre class=\"command-line\">$ find . -name *~ -exec rm {}\\;\r\nfind: -exec: no terminating \";\" or \"+\"\r\n<\/pre>\n<\/li>\n<li>To execute more than one command, specify multiple -exec.<\/li>\n<\/ul>\n<p>Example:<\/p>\n<pre class=\"command-line\">find ~ -name '*bak' -exec rm {} \\;\r\n<\/pre>\n<ul>\n<li>\nIn above example, \"rm {} \\;\" following \"-exec\" is the command to execute. Last \";\" denotes the end of the parameters. \"\\\" before \";\" is needed to escape \"\\\" so that shell does not evaluate \";\".\n<\/li>\n<\/ul>\n<p>Example:<\/p>\n<p>Delete all files whose name are *~ (Emacs backup file) in home directory.<\/p>\n<pre class=\"command-line\">$ find ~\/ -name \"*~\" -exec rm {} \\;\r\n<\/pre>\n<p>Delete all .svn directories from working directory tree of Subversion.<\/p>\n<pre class=\"command-line\">find . -name .svn -exec rm -rf {} \\;\r\n<\/pre>\n<p>Grep files in directory tree.<br \/>\n\uff08grep option -H for printing filename headers, -n for printing line number\uff09<\/p>\n<pre class=\"command-line\">find &lt;directory&gt; -type f -exec grep -nH &lt;pattern&gt; {} \\;\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>-exec command {} \\; Execute command after find. To pass results of find use {}. You must put a blank before \"\\ &hellip; <a href=\"https:\/\/www.pistolfly.com\/weblog\/en\/2009\/06\/delete-or-grep-the-results-of-find.html\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Delete or grep the results of find<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_locale":"en_US","_original_post":"827","_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[6],"tags":[],"class_list":["post-3309","post","type-post","status-publish","format-standard","hentry","category-linux","en-US"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Delete or grep the results of find - Pistolfly<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.pistolfly.com\/weblog\/en\/2009\/06\/delete-or-grep-the-results-of-find.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Delete or grep the results of find - Pistolfly\" \/>\n<meta property=\"og:description\" content=\"-exec command {} ; Execute command after find. To pass results of find use {}. You must put a blank before &quot; &hellip; Continue reading Delete or grep the results of find &rarr;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.pistolfly.com\/weblog\/en\/2009\/06\/delete-or-grep-the-results-of-find.html\" \/>\n<meta property=\"og:site_name\" content=\"Pistolfly\" \/>\n<meta property=\"article:published_time\" content=\"2009-06-07T01:26:20+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2018-04-01T11:54:08+00:00\" \/>\n<meta name=\"author\" content=\"Pistolfly\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Pistolfly\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.pistolfly.com\\\/weblog\\\/en\\\/2009\\\/06\\\/delete-or-grep-the-results-of-find.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.pistolfly.com\\\/weblog\\\/en\\\/2009\\\/06\\\/delete-or-grep-the-results-of-find.html\"},\"author\":{\"name\":\"Pistolfly\",\"@id\":\"https:\\\/\\\/www.pistolfly.com\\\/weblog\\\/#\\\/schema\\\/person\\\/e779e918730b507907b3a35b77a9a2ab\"},\"headline\":\"Delete or grep the results of find\",\"datePublished\":\"2009-06-07T01:26:20+00:00\",\"dateModified\":\"2018-04-01T11:54:08+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.pistolfly.com\\\/weblog\\\/en\\\/2009\\\/06\\\/delete-or-grep-the-results-of-find.html\"},\"wordCount\":112,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.pistolfly.com\\\/weblog\\\/#\\\/schema\\\/person\\\/e779e918730b507907b3a35b77a9a2ab\"},\"articleSection\":[\"Linux\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.pistolfly.com\\\/weblog\\\/en\\\/2009\\\/06\\\/delete-or-grep-the-results-of-find.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.pistolfly.com\\\/weblog\\\/en\\\/2009\\\/06\\\/delete-or-grep-the-results-of-find.html\",\"url\":\"https:\\\/\\\/www.pistolfly.com\\\/weblog\\\/en\\\/2009\\\/06\\\/delete-or-grep-the-results-of-find.html\",\"name\":\"Delete or grep the results of find - Pistolfly\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.pistolfly.com\\\/weblog\\\/#website\"},\"datePublished\":\"2009-06-07T01:26:20+00:00\",\"dateModified\":\"2018-04-01T11:54:08+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.pistolfly.com\\\/weblog\\\/en\\\/2009\\\/06\\\/delete-or-grep-the-results-of-find.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.pistolfly.com\\\/weblog\\\/en\\\/2009\\\/06\\\/delete-or-grep-the-results-of-find.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.pistolfly.com\\\/weblog\\\/en\\\/2009\\\/06\\\/delete-or-grep-the-results-of-find.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u30db\u30fc\u30e0\",\"item\":\"https:\\\/\\\/www.pistolfly.com\\\/weblog\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Delete or grep the results of find\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.pistolfly.com\\\/weblog\\\/#website\",\"url\":\"https:\\\/\\\/www.pistolfly.com\\\/weblog\\\/\",\"name\":\"Pistolfly\",\"description\":\"Developer Blog\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.pistolfly.com\\\/weblog\\\/#\\\/schema\\\/person\\\/e779e918730b507907b3a35b77a9a2ab\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.pistolfly.com\\\/weblog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/www.pistolfly.com\\\/weblog\\\/#\\\/schema\\\/person\\\/e779e918730b507907b3a35b77a9a2ab\",\"name\":\"Pistolfly\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/0b3ddb2859adabf28a2b97ae9fff98772ddffc46088d11cad2b9a2cef66115e7?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/0b3ddb2859adabf28a2b97ae9fff98772ddffc46088d11cad2b9a2cef66115e7?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/0b3ddb2859adabf28a2b97ae9fff98772ddffc46088d11cad2b9a2cef66115e7?s=96&d=mm&r=g\",\"caption\":\"Pistolfly\"},\"logo\":{\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/0b3ddb2859adabf28a2b97ae9fff98772ddffc46088d11cad2b9a2cef66115e7?s=96&d=mm&r=g\"},\"description\":\"Software Engineer in Tokyo, Japan\",\"url\":\"https:\\\/\\\/www.pistolfly.com\\\/weblog\\\/author\\\/pistolfly\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Delete or grep the results of find - Pistolfly","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.pistolfly.com\/weblog\/en\/2009\/06\/delete-or-grep-the-results-of-find.html","og_locale":"en_US","og_type":"article","og_title":"Delete or grep the results of find - Pistolfly","og_description":"-exec command {} ; Execute command after find. To pass results of find use {}. You must put a blank before \" &hellip; Continue reading Delete or grep the results of find &rarr;","og_url":"https:\/\/www.pistolfly.com\/weblog\/en\/2009\/06\/delete-or-grep-the-results-of-find.html","og_site_name":"Pistolfly","article_published_time":"2009-06-07T01:26:20+00:00","article_modified_time":"2018-04-01T11:54:08+00:00","author":"Pistolfly","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Pistolfly","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.pistolfly.com\/weblog\/en\/2009\/06\/delete-or-grep-the-results-of-find.html#article","isPartOf":{"@id":"https:\/\/www.pistolfly.com\/weblog\/en\/2009\/06\/delete-or-grep-the-results-of-find.html"},"author":{"name":"Pistolfly","@id":"https:\/\/www.pistolfly.com\/weblog\/#\/schema\/person\/e779e918730b507907b3a35b77a9a2ab"},"headline":"Delete or grep the results of find","datePublished":"2009-06-07T01:26:20+00:00","dateModified":"2018-04-01T11:54:08+00:00","mainEntityOfPage":{"@id":"https:\/\/www.pistolfly.com\/weblog\/en\/2009\/06\/delete-or-grep-the-results-of-find.html"},"wordCount":112,"commentCount":0,"publisher":{"@id":"https:\/\/www.pistolfly.com\/weblog\/#\/schema\/person\/e779e918730b507907b3a35b77a9a2ab"},"articleSection":["Linux"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.pistolfly.com\/weblog\/en\/2009\/06\/delete-or-grep-the-results-of-find.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.pistolfly.com\/weblog\/en\/2009\/06\/delete-or-grep-the-results-of-find.html","url":"https:\/\/www.pistolfly.com\/weblog\/en\/2009\/06\/delete-or-grep-the-results-of-find.html","name":"Delete or grep the results of find - Pistolfly","isPartOf":{"@id":"https:\/\/www.pistolfly.com\/weblog\/#website"},"datePublished":"2009-06-07T01:26:20+00:00","dateModified":"2018-04-01T11:54:08+00:00","breadcrumb":{"@id":"https:\/\/www.pistolfly.com\/weblog\/en\/2009\/06\/delete-or-grep-the-results-of-find.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.pistolfly.com\/weblog\/en\/2009\/06\/delete-or-grep-the-results-of-find.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.pistolfly.com\/weblog\/en\/2009\/06\/delete-or-grep-the-results-of-find.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u30db\u30fc\u30e0","item":"https:\/\/www.pistolfly.com\/weblog"},{"@type":"ListItem","position":2,"name":"Delete or grep the results of find"}]},{"@type":"WebSite","@id":"https:\/\/www.pistolfly.com\/weblog\/#website","url":"https:\/\/www.pistolfly.com\/weblog\/","name":"Pistolfly","description":"Developer Blog","publisher":{"@id":"https:\/\/www.pistolfly.com\/weblog\/#\/schema\/person\/e779e918730b507907b3a35b77a9a2ab"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.pistolfly.com\/weblog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/www.pistolfly.com\/weblog\/#\/schema\/person\/e779e918730b507907b3a35b77a9a2ab","name":"Pistolfly","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/0b3ddb2859adabf28a2b97ae9fff98772ddffc46088d11cad2b9a2cef66115e7?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/0b3ddb2859adabf28a2b97ae9fff98772ddffc46088d11cad2b9a2cef66115e7?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/0b3ddb2859adabf28a2b97ae9fff98772ddffc46088d11cad2b9a2cef66115e7?s=96&d=mm&r=g","caption":"Pistolfly"},"logo":{"@id":"https:\/\/secure.gravatar.com\/avatar\/0b3ddb2859adabf28a2b97ae9fff98772ddffc46088d11cad2b9a2cef66115e7?s=96&d=mm&r=g"},"description":"Software Engineer in Tokyo, Japan","url":"https:\/\/www.pistolfly.com\/weblog\/author\/pistolfly"}]}},"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/paorzz-Rn","jetpack-related-posts":[],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.pistolfly.com\/weblog\/wp-json\/wp\/v2\/posts\/3309","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.pistolfly.com\/weblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.pistolfly.com\/weblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.pistolfly.com\/weblog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.pistolfly.com\/weblog\/wp-json\/wp\/v2\/comments?post=3309"}],"version-history":[{"count":13,"href":"https:\/\/www.pistolfly.com\/weblog\/wp-json\/wp\/v2\/posts\/3309\/revisions"}],"predecessor-version":[{"id":4349,"href":"https:\/\/www.pistolfly.com\/weblog\/wp-json\/wp\/v2\/posts\/3309\/revisions\/4349"}],"wp:attachment":[{"href":"https:\/\/www.pistolfly.com\/weblog\/wp-json\/wp\/v2\/media?parent=3309"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.pistolfly.com\/weblog\/wp-json\/wp\/v2\/categories?post=3309"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.pistolfly.com\/weblog\/wp-json\/wp\/v2\/tags?post=3309"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}