{"id":2188,"date":"2017-03-25T14:50:48","date_gmt":"2017-03-25T09:20:48","guid":{"rendered":"https:\/\/www.wikitechy.com\/technology\/?p=2188"},"modified":"2017-03-28T15:33:41","modified_gmt":"2017-03-28T10:03:41","slug":"make-ls-show-file-sizes-megabytes","status":"publish","type":"post","link":"https:\/\/www.wikitechy.com\/technology\/make-ls-show-file-sizes-megabytes\/","title":{"rendered":"LINUX &#8211; How do you make `ls` show file sizes in megabytes?"},"content":{"rendered":"<ul>\n<li>ls -l &#8211;block-size=M will give you a long format listing (needed to actually see the file size) and round file sizes up to the nearest MiB.<\/li>\n<li>If you want MB (10^6 bytes) rather than MiB (2^20 bytes) units, use &#8211;block-size=MB instead.<\/li>\n<li>If you don&#8217;t want the M suffix attached to the file size, you can use something like &#8211;block-size=1M.<\/li>\n<li>This is described in the man page for ls; man ls and search for SIZE. It allows for units other than MB\/MiB as well, and from the looks of it arbitrary block sizes as well (so you could see the file size as number of 412-byte blocks, if you want to).<\/li>\n<li>Note that the &#8211;block-size parameter is a GNU extension on top of the Open Group&#8217;s ls, so this may not work if you don&#8217;t have a GNU userland (which most Linux installations do). The ls from GNU coreutils 8.5 does support &#8211;block-size as described above.<\/li>\n<\/ul>\n[ad type=&#8221;banner&#8221;]\n<h4 id=\"maybe-h-is-sufficient-for-you\"><span style=\"color: #800000;\">Maybe -h is sufficient for you:<\/span><\/h4>\n<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <span class=\"code-embed-name\">Bash Code<\/span> <\/div> <pre class=\"language-bash code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-bash code-embed-code\">  -h <\/code><\/pre> <\/div>\n<p>When used with the -l option, use unit suffixes: Byte, Kilobyte, Megabyte, Gigabyte, Terabyte and Petabyte in order to reduce the number of digits to three or less using base 2 for sizes.<\/p>\n<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <span class=\"code-embed-name\">Bash Code<\/span> <\/div> <pre class=\"language-bash code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-bash code-embed-code\">ls -lah<\/code><\/pre> <\/div>\n[ad type=&#8221;banner&#8221;]\n<p>Use man commandname to read the manual of a certain commend, e.g. here man ls.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>ls -l &#8211;block-size=M will give you a long format listing (needed to actually see the file size) and round file sizes up to the nearest MiB. If you want MB (10^6 bytes) rather than MiB (2^20 bytes) units, use &#8211;block-size=MB instead. If you don&#8217;t want the M suffix attached to the file size, you can [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1699],"tags":[4746,4754,4748,4750,4756,4752,4744,4751,4755,4749,4743,4745,4753,4747],"class_list":["post-2188","post","type-post","status-publish","format-standard","hentry","category-linux","tag-ext3-if-block-size-is-4k","tag-gb-with-ls-in-linux","tag-get-file-size-and-line-count-at-the-same-time","tag-how-do-i-do-a-long-listing-of-files-and-only-show-those-that-are-a-certain-size","tag-how-do-i-make-ls-show-file-sizes-in-megabytes","tag-how-do-i-view-file-sizes-kb","tag-how-to-list-all-files-ordered-by-size","tag-is-there-a-way-to-show-the-permissions-for-a-file-without-using-ls","tag-linux-ls-to-show-file-size-in-gb-or-mb","tag-list-all-files-that-end-in-ball-using-ls-command","tag-ls-to-show-only-directoryfilename-and-size","tag-maximum-number-of-files-ls-can-list","tag-mb","tag-why-does-ls-l-show-file-sizes-below-that"],"_links":{"self":[{"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/posts\/2188","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/comments?post=2188"}],"version-history":[{"count":0,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/posts\/2188\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/media?parent=2188"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/categories?post=2188"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/tags?post=2188"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}