{"id":176,"date":"2026-04-19T10:32:07","date_gmt":"2026-04-19T09:32:07","guid":{"rendered":"https:\/\/vpp.dk\/?linux_trick=count-lines-words-bytes-in-a-file"},"modified":"2026-04-19T10:32:07","modified_gmt":"2026-04-19T09:32:07","slug":"count-lines-words-bytes-in-a-file","status":"publish","type":"linux_trick","link":"https:\/\/vpp.dk\/?linux_trick=count-lines-words-bytes-in-a-file","title":{"rendered":"Count lines \/ words \/ bytes in a file"},"content":{"rendered":"<p>wc is the Swiss Army knife for file statistics. Combine flags or chain with other commands.<\/p>\n","protected":false},"template":"","meta":{"_trick_code":"wc -l file.txt          # lines\nwc -w file.txt          # words\nwc -c file.txt          # bytes\n\n# Count non-empty lines:\ngrep -c . file.txt\n\n# Total lines across multiple files:\nwc -l *.log | tail -1","_trick_uploader":"wordcounter"},"trick_category":[19],"class_list":["post-176","linux_trick","type-linux_trick","status-publish","hentry","trick_category-text-processing"],"_links":{"self":[{"href":"https:\/\/vpp.dk\/index.php?rest_route=\/wp\/v2\/linux_trick\/176","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/vpp.dk\/index.php?rest_route=\/wp\/v2\/linux_trick"}],"about":[{"href":"https:\/\/vpp.dk\/index.php?rest_route=\/wp\/v2\/types\/linux_trick"}],"wp:attachment":[{"href":"https:\/\/vpp.dk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=176"}],"wp:term":[{"taxonomy":"trick_category","embeddable":true,"href":"https:\/\/vpp.dk\/index.php?rest_route=%2Fwp%2Fv2%2Ftrick_category&post=176"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}