What does the -h option do in the ls command?

The -h option in the ls command is used to display file sizes in a human-readable format.

Key Features of -h:

  • Readable Sizes: When used with the -l option (i.e., ls -lh), it converts file sizes from bytes into more understandable units such as kilobytes (KB), megabytes (MB), or gigabytes (GB).
  • Easier Interpretation: This makes it simpler for users to quickly assess the size of files without needing to mentally convert large byte values.

Example:

When you run ls -lh, the output might look like this:

-rw-r--r-- 1 user group 1.5K Jan 01 12:00 file.txt
drwxr-xr-x 2 user group 4.0K Jan 01 12:00 directory

Here, 1.5K indicates that the file size is 1.5 kilobytes, making it much clearer than just showing the raw byte count.

If you have more questions or need further clarification, feel free to ask!

0 Comments

no data
Be the first to share your comment!