{"id":1456,"date":"2018-07-10T11:08:02","date_gmt":"2018-07-10T09:08:02","guid":{"rendered":"http:\/\/clark.tipistrani.it\/?p=1456"},"modified":"2021-12-03T14:07:40","modified_gmt":"2021-12-03T13:07:40","slug":"contare-i-files-in-una-directory","status":"publish","type":"post","link":"http:\/\/clark.tipistrani.it\/?p=1456","title":{"rendered":"Contare i files in una directory"},"content":{"rendered":"<p>Pu\u00f2 sembrare banale ma certe volte si rende necessario sapere quanti files ci sono in una directory,pu\u00f2 essere necessario sapere quanti files in totale oppure quanti di un certo tipo ad esempio quanti .pdf<br \/>\nIl comando find \u00e8 esattamente quello che serve, una scrittura di questo tipo:<\/p>\n<p>find . -type f | wc -l<br \/>\nconter\u00e0 tutti i files di qualsiasi tipo nella directory corrente e nelle sue subdir<br \/>\nuna scrittura di questo tipo:<br \/>\nfind . -type f -iname *.pdf | wc -l<br \/>\nconter\u00e0 tutti i files con estensione .pdf a prescindere che minuscola o maiuscola<br \/>\n(flag -iname).<\/p>\n<p>Se poi mi serve anche sapere quanto &#8220;pesano&#8221; i files in questione allora uso:<br \/>\nfind . -type f -iname *.pdf -print0 | du &#8211; -files0-from=- -hc | tail -n1<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Pu\u00f2 sembrare banale ma certe volte si rende necessario sapere quanti files ci sono in una directory,pu\u00f2 essere necessario sapere quanti files in totale oppure quanti di un certo tipo ad esempio quanti .pdf Il comando find \u00e8 esattamente quello che serve, una scrittura di questo tipo: find . -type f | wc -l conter\u00e0 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8,6],"tags":[130,127,129],"class_list":["post-1456","post","type-post","status-publish","format-standard","hentry","category-linux","category-work","tag-files","tag-find","tag-wc"],"_links":{"self":[{"href":"http:\/\/clark.tipistrani.it\/index.php?rest_route=\/wp\/v2\/posts\/1456","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/clark.tipistrani.it\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/clark.tipistrani.it\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/clark.tipistrani.it\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/clark.tipistrani.it\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1456"}],"version-history":[{"count":9,"href":"http:\/\/clark.tipistrani.it\/index.php?rest_route=\/wp\/v2\/posts\/1456\/revisions"}],"predecessor-version":[{"id":2075,"href":"http:\/\/clark.tipistrani.it\/index.php?rest_route=\/wp\/v2\/posts\/1456\/revisions\/2075"}],"wp:attachment":[{"href":"http:\/\/clark.tipistrani.it\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1456"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/clark.tipistrani.it\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1456"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/clark.tipistrani.it\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1456"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}