{"id":3411,"date":"2014-08-04T09:13:00","date_gmt":"2014-08-04T01:13:00","guid":{"rendered":"http:\/\/rmohan.com\/?p=3411"},"modified":"2014-08-04T09:13:00","modified_gmt":"2014-08-04T01:13:00","slug":"ls","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=3411","title":{"rendered":"ls"},"content":{"rendered":"<p>I always find it difficult to digest the filesize from the ls -al command. For instance, after ls -al, the output give me filesize in bytes.<\/p>\n<p>Gosh, then I have to start calculating it by taking last 4 digits, slowly count upwards like 1K, 10K, 100K, 1MB, 10MB, 100MB and so on so forth.<\/p>\n<p>For instance:<\/p>\n<p>this output:<br \/>\n-rw-r&#8211;r&#8211; 1 walrus dba 137207094 Jul 8 23:12 config.2008032519.s<\/p>\n<p>137207094 is how much?<\/p>\n<p>going with my method of counting upwards, it gives me 137MB roughly.<\/p>\n<p>Is it correct? WRONG. Hell wrong<\/p>\n<p>The above is bits only. Bear in mind, 1 KB = 1024 bits, 1 MB = 1024 KB and so on so forth<\/p>\n<p>[ Source ]<br \/>\n1 bit = a 1 or 0 (b)<br \/>\n4 bits = 1 nybble (?)<br \/>\n8 bits = 1 byte (B)<br \/>\n1024 bytes = 1 Kilobyte (KB)<br \/>\n1024 Kilobytes = 1 Megabyte (MB)<br \/>\n1024 Megabytes = 1 Gigabyte (GB)<br \/>\n1024 Gigabytes = 1 Terabyte (TB)<\/p>\n<p>The correct calculation is 137207094 \/ 1024 (bits) \/ 1024 (KB) = 130.8 MB<\/p>\n<p>Starting in Solaris 10, we have a new option in ls command.<\/p>\n<p>: \/u01\/apps\/WatchMark\/FlexPM\/classic\/vendor\/Lucent\/ECP\/ftpIN\/in>uname -a<br \/>\nSunOS lxserver 5.10 Generic_118833-36 sun4u sparc SUNW,Sun-Fire-V445<\/p>\n<p>ANCIENT WAY:<br \/>\nls -al<br \/>\ntotal 270388<br \/>\ndrwxr-xr-x 2 walrus dba 1024 Jul 8 23:14 .<br \/>\ndrwxr-xr-x 11 walrus dba 512 Jun 17 01:49 ..<br \/>\n-rw-r&#8211;r&#8211; 1 walrus dba 137207094 Jul 8 23:12 config.2008032519.s<br \/>\n-rw-r&#8211;r&#8211; 1 walrus dba 451989 Jul 8 23:12 config.2008032519.split0.bz<\/p>\n<p>cons: hard to read filesize and output distorted<\/p>\n<p>NEW WAY:<br \/>\nls -alh<br \/>\ntotal 269060<br \/>\ndrwxr-xr-x 2 flexpm dba 1.0K Jul 8 23:12 .<br \/>\ndrwxr-xr-x 11 flexpm dba 512 Jun 17 01:49 ..<br \/>\n-rw-r&#8211;r&#8211; 1 flexpm dba 131M Jul 8 23:12 config.2008032519.s<br \/>\n-rw-r&#8211;r&#8211; 1 flexpm dba 441K Jul 8 23:12 config.2008032519.split0.sm.gz<\/p>\n<p>pros:<br \/>\n&#8211; more readable format in terms of file size<br \/>\n&#8211; contents are properly aligned.<\/p>\n<p>cons:<br \/>\n&#8211; need to type extra &#8216;h&#8217; at the end of ls command<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I always find it difficult to digest the filesize from the ls -al command. For instance, after ls -al, the output give me filesize in bytes.<\/p>\n<p>Gosh, then I have to start calculating it by taking last 4 digits, slowly count upwards like 1K, 10K, 100K, 1MB, 10MB, 100MB and so on so forth.<\/p>\n<p>For [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[47],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/3411"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3411"}],"version-history":[{"count":1,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/3411\/revisions"}],"predecessor-version":[{"id":3412,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/3411\/revisions\/3412"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3411"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3411"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3411"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}