#18 Displaying the Contents of Directories

While the ls command is a cornerstone of working with the Unix command line, there's one element of the command that's always seemed pointless to me: indicating the size of a directory. When a directory is listed, the program either lists the directory's contents file by file or shows the number of 1,024-byte blocks required for the directory data. A typical entry in an ls -l output might be

drwxrwxr-x    2 taylor   taylor       4096 Oct 28 19:07 bin

But that's really not very useful, because what I want to know is how many files are in the specified directory. That's what this script accomplishes, generating a nice multicolumn listing of files and directories that shows file size with file entries and ...

Get Wicked Cool Shell Scripts now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.