Skip to main content
9 events
when toggle format what by license comment
Nov 29, 2022 at 14:24 comment added MattDMo @Dave in my function I use ls -FAGl, which does not include . and ...
May 17, 2022 at 17:42 comment added Dave I maybe mistaken but this outputs the total of everything ls lists... so this includes . and .. in the total. That skews the data as it includes totals of files in other directories.
Aug 23, 2021 at 18:08 comment added Marcelo Idemax du -ch **/*.ext|tail -1 works pretty fine
Jun 6, 2020 at 17:21 comment added MattDMo @DmitryShevkoplyas running Cygwin bash on Windows, ls -a reports the size of . and .. as 0 bytes, so it doesn't affect the total. However, your point is valid on Linux and OSX, so I've changed my function definition of dir accordingly. Thanks!
Sep 11, 2019 at 14:39 comment added Dmitry Shevkoplyas Please fix so it works on both Linux and OS-S and your "-a" include "." and "..", which is not good : ) Here's the fixed command: dir () { ls -FAl "${@}" | awk '{ total += $5; print }; END { print "total:"total }'; }
Nov 3, 2017 at 8:18 comment added dessert dir is already the name of a popular GNU coreutil, I'd rather not name a function like that.
Jan 10, 2017 at 20:20 comment added Jon V This is true, if you're looking for essentially the contents size of each file, NOT the size the file consumes on disk. This distinction is more pronounced for very small files. On my distro's each file is allocated space on disk in 4 KB chunks (so a 300 byte file still uses 4K on a disk, as reported by the du command). Given that's what the OP was looking for "how much space each file takes up", then du is the way to do it.
Apr 17, 2013 at 17:47 vote accept MattDMo
Apr 16, 2013 at 18:59 history answered user27282 CC BY-SA 3.0