Tutorial: How to view a specific file size in a human readable format (Linux)
Linux users will most commonly use the command "ls -l" to display a list of the files in the current they are in. Sometimes even "ls -a -l" to display ALL files, including any hidden ones. This works just fine but sometimes you have files that are several hunder megabytes or even gigabytes. The "ls -l" command displays the file list with a size in "bytes". I don't know about you, but I am not a human calculator and it just turns into a long number that I have to translate to figure out how many megabytes or gigabytes the file may be.
I now introduce the command
du -h <filename>
With this command it will display the file you specifiy in a 'human readable" format. For example:
du – h file.tar.gz
This will return:
Now that's what I can a human readble file size! Check out the man page below for "du".
du man page
du – estimate file space usage
du [OPTION]… [FILE]…
Summarize disk usage of each FILE, recursively for directories.
Mandatory arguments to long options are mandatory for short options too.
write counts for all files, not just directories
-B, –block-size=SIZE use SIZE-byte blocks
print size in bytes
produce a grand total
dereference FILEs that are symbolic links
print sizes in human readable format (e.g., 1K 234M 2G)
likewise, but use powers of 1000 not 1024
count sizes many times if hard linked
dereference all symbolic links
do not include size of subdirectories
display only a total for each argument
skip directories on different filesystems
-X FILE, –exclude-from=FILE
Exclude files that match any pattern in FILE.
–exclude=PATTERN Exclude files that match PATTERN.
print the total for a directory (or file, with –all) only if it is N or fewer levels below the command line argument; –max-depth=0 is the same as –summarize
display this help and exit
output version information and exit