{"id":586,"date":"2019-09-21T17:02:22","date_gmt":"2019-09-21T17:02:22","guid":{"rendered":"https:\/\/nmbm.biz\/sitio\/?p=586"},"modified":"2022-03-02T12:50:31","modified_gmt":"2022-03-02T12:50:31","slug":"eliminar-ou-mover-ficheiros-em-lote-no-sistema-linux","status":"publish","type":"post","link":"https:\/\/blog.webgescom.pt\/blog\/eliminar-ou-mover-ficheiros-em-lote-no-sistema-linux\/","title":{"rendered":"Eliminar ou mover ficheiros em lote no sistema Linux"},"content":{"rendered":"\n<p>A <em>shell<\/em> do Linux tem ferramentas poderosas no que toca a automatizar procedimentos. Uma delas \u00e9 o comando <em>find<\/em>, que permite eliminar ou mover ficheiros com mais do que n dias.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Eliminar Ficheiros<\/h4>\n\n\n\n<pre class=\"wp-block-preformatted\"> find \/path-fich\/ -type f -name '*.jpg' -mtime +30 -exec rm {} \\; <\/pre>\n\n\n\n<p><strong>Explica\u00e7\u00e3o do comando:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>o primeiro par\u00e2metro (<em>path-fich<\/em>) \u00e9 o caminho onde procurar;<\/li><li><em>-type f<\/em> &#8211; tipo de objecto: ficheiro;<\/li><li>terceiro par\u00e2metro: filtro, no caso ficheiros jpg (n\u00e3o usar o wildcard em resultados muito extensos. D\u00e1 o erro  <em>Argument list too long<\/em>);<\/li><li>tempo (-mtime) &#8211; no exemplo, lista ficheiros com mais de 30 dias;<\/li><li>execu\u00e7\u00e3o de comando (-exec). no caso, executa o comando <em>rm<\/em> com cada elemento obtido na pesquisa;<\/li><li>\\; termina o comando a executar;<\/li><\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">Mover Ficheiros<\/h4>\n\n\n\n<pre class=\"wp-block-preformatted\"> find \/path-fich\/ -type f -name '*.jpg' -mtime +30 -exec mv {} \/path-pasta-arquivo\/ \\; <\/pre>\n\n\n\n<p>Adaptado do artigo escrito em:  <a href=\"https:\/\/www.vionblog.com\/linux-delete-files-older-than-x-days\/\">https:\/\/www.vionblog.com\/linux-delete-files-older-than-x-days\/<\/a> <\/p>\n<div class=\"pvc_clear\"><\/div><p id=\"pvc_stats_586\" class=\"pvc_stats all  \" data-element-id=\"586\" style=\"\"><i class=\"pvc-stats-icon small\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/blog.webgescom.pt\/blog\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p><div class=\"pvc_clear\"><\/div>","protected":false},"excerpt":{"rendered":"<p>A shell do Linux tem ferramentas poderosas no que toca a automatizar procedimentos. Uma delas \u00e9 o comando find, que permite eliminar ou mover ficheiros com mais do que n dias. Eliminar Ficheiros find \/path-fich\/ -type f -name &#8216;*.jpg&#8217; -mtime +30 -exec rm {} \\; Explica\u00e7\u00e3o do comando: o primeiro par\u00e2metro (path-fich) \u00e9 o caminho&hellip;&nbsp;<\/p>\n<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_586\" class=\"pvc_stats all  \" data-element-id=\"586\" style=\"\"><i class=\"pvc-stats-icon small\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/blog.webgescom.pt\/blog\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"neve_meta_sidebar":"","neve_meta_container":"","neve_meta_enable_content_width":"","neve_meta_content_width":0,"neve_meta_title_alignment":"","neve_meta_author_avatar":"","neve_post_elements_order":"","neve_meta_disable_header":"","neve_meta_disable_footer":"","neve_meta_disable_title":"","footnotes":""},"categories":[9,144],"tags":[129,11,130,131],"class_list":["post-586","post","type-post","status-publish","format-standard","hentry","category-linux","category-sistemas","tag-find","tag-linux","tag-mv","tag-rm"],"aioseo_notices":[],"a3_pvc":{"activated":true,"total_views":2224,"today_views":0},"_links":{"self":[{"href":"https:\/\/blog.webgescom.pt\/blog\/wp-json\/wp\/v2\/posts\/586","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.webgescom.pt\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.webgescom.pt\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.webgescom.pt\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.webgescom.pt\/blog\/wp-json\/wp\/v2\/comments?post=586"}],"version-history":[{"count":3,"href":"https:\/\/blog.webgescom.pt\/blog\/wp-json\/wp\/v2\/posts\/586\/revisions"}],"predecessor-version":[{"id":953,"href":"https:\/\/blog.webgescom.pt\/blog\/wp-json\/wp\/v2\/posts\/586\/revisions\/953"}],"wp:attachment":[{"href":"https:\/\/blog.webgescom.pt\/blog\/wp-json\/wp\/v2\/media?parent=586"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.webgescom.pt\/blog\/wp-json\/wp\/v2\/categories?post=586"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.webgescom.pt\/blog\/wp-json\/wp\/v2\/tags?post=586"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}