UNIX file size listing – du command
| Posted by watashii | Filed under Programming, UnixQuestion: How can I list the true file and directory sizes on UNIX?
boadmin@nshost1>$ ls -la
total 12130522
drwxr-xr-x 5 boadmin boadmin 512 Aug 4 14:30 .
drwxr-xr-x 31 boadmin boadmin 1024 Aug 1 22:00 ..
drwxr-xr-x 5 boadmin boadmin 512 May 7 05:48 DISK_1
drwxr-xr-x 3 boadmin boadmin 512 May 7 05:47 DISK_2
drwxr-xr-x 3 boadmin boadmin 512 May 31 14:02 sp3
-rw-r--r-- 1 boadmin boadmin 6207767040 Aug 4 14:33 sp3.tar
The short answer, use the following command: du -sh *
boadmin@nshost1>$ du -sh *
634M DISK_1
152M DISK_2
5.8G sp3
5.8G sp3.tar
du - is the disk usage utility on UNIX
s - is to sum the files within the directory
h - is the filesize in human readable format, megs, gigs, etc
* - to group it on all elements in the current directory, or specify
any path here, or leave empty to summarize to one group
The long answer, use the following command and start reading: man du
Related Posts:
- Unix ps command – Long Process Listing
- Unix LS Command With Colors… Without the —color Option
- Unix – Creating Cron Jobs with Crontab
- Unix Shell – Check If Directory Is Empty
- Unix Split, Join & Validate Files
Tags: directory size, du, file size, size listing, unix
