When using the terminal, is there a command that allows you to see the size of each individual file in a particular directory?
3 Answers
On Linux/Unix, use
ls -lk
(for size in kilobyte) orls -lh
(for easier readable approximate file sizes, like12M
or2G
).
ls -l
will show size in blocks, which might not be that useful.
Use ls -l
to list all files with their details on OS X and Linux, or dir
on Windows.
-
man ls
would get you far but just to add to Darth's answer, adding-h
will help you get a more human-readable output!– GarrettDec 30, 2011 at 7:21
I'm late to the party! ls -lh
works if you don't want to know the size of directories with their content (all the directories just get listed as being 4 kilobytes).
Example output of ls
command:
$ ls -lh
total 796K
drwxr-xr-x. 2 user user 4.0K Sep 25 20:04 Desktop
drwxr-xr-x. 7 user user 4.0K Aug 13 23:48 Documents
drwxr-xr-x. 6 user user 4.0K Nov 21 18:27 Downloads
drwx------. 12 user user 4.0K Nov 21 10:06 Dropbox
-rw-rw-r-- 1 user user 5 Nov 21 22:06 file1
-rw-rw-r-- 1 user user 751K Nov 21 22:06 file2
...
May I suggest du -h -s /path/to/dir/*
Example output of du
command:
$ du -h -s *
4.0K Desktop
980M Documents
3.7G Downloads
5.0G Dropbox
4.0K file1
752K file2
...
Be ready to sit back and wait. Depending on how big the contents of the folder are and your IO speed, du can take quite a while.