{"id":1444,"date":"2008-08-18T12:23:36","date_gmt":"2008-08-18T17:23:36","guid":{"rendered":"http:\/\/blogs.terrorware.com\/geoff\/2008\/08\/18\/passing-grep-results-to-other-unix-commands\/"},"modified":"2008-08-18T15:54:10","modified_gmt":"2008-08-18T20:54:10","slug":"passing-grep-results-to-other-unix-commands","status":"publish","type":"post","link":"http:\/\/blogs.terrorware.com\/geoff\/2008\/08\/18\/passing-grep-results-to-other-unix-commands\/","title":{"rendered":"passing grep results to other unix commands"},"content":{"rendered":"<p>This is old news to a lot of folks, but new and powerful to me.<\/p>\n<h3>Search for text in files and move matching files<\/h3>\n<blockquote>\n<pre>$ grep --files-with-matches --null foo * | xargs --null -I xxx mv xxx dir_for_foos\/<\/pre>\n<\/blockquote>\n<p>The above command searches for the string foo in all files in the current subdirectory.\u00c2\u00a0 It then moves each file to a specified directory.<\/p>\n<h3>Read a list of files from a text file and move those files somewhere<\/h3>\n<blockquote>\n<pre>$ xargs -a ok.txt\u00c2\u00a0 -I xxx mv xxx \/var\/lib\/accounting\/joblogs\/parsed<\/pre>\n<\/blockquote>\n<blockquote><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>This is old news to a lot of folks, but new and powerful to me. Search for text in files and move matching files $ grep &#8211;files-with-matches &#8211;null foo * | xargs &#8211;null -I xxx mv xxx dir_for_foos\/ The above command searches for the string foo in all files in the current subdirectory.\u00c2\u00a0 It then&hellip; <a class=\"more-link\" href=\"http:\/\/blogs.terrorware.com\/geoff\/2008\/08\/18\/passing-grep-results-to-other-unix-commands\/\">Continue reading <span class=\"screen-reader-text\">passing grep results to other unix commands<\/span><\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[1],"tags":[560,267,266,561],"class_list":["post-1444","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-grep","tag-shell","tag-unix","tag-xargs","entry"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p4wnIz-ni","_links":{"self":[{"href":"http:\/\/blogs.terrorware.com\/geoff\/wp-json\/wp\/v2\/posts\/1444","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/blogs.terrorware.com\/geoff\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blogs.terrorware.com\/geoff\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blogs.terrorware.com\/geoff\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"http:\/\/blogs.terrorware.com\/geoff\/wp-json\/wp\/v2\/comments?post=1444"}],"version-history":[{"count":0,"href":"http:\/\/blogs.terrorware.com\/geoff\/wp-json\/wp\/v2\/posts\/1444\/revisions"}],"wp:attachment":[{"href":"http:\/\/blogs.terrorware.com\/geoff\/wp-json\/wp\/v2\/media?parent=1444"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blogs.terrorware.com\/geoff\/wp-json\/wp\/v2\/categories?post=1444"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blogs.terrorware.com\/geoff\/wp-json\/wp\/v2\/tags?post=1444"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}