HowTo: Linux / Unix See File Size Command

https:/‮‬/www.lautturi.com
HowTo: Linux / Unix See File Size Command

To see the size of a file in Linux or Unix, you can use the ls command with the -l option, which displays the size of the file in bytes:

ls -l file.txt

This will show the file size in bytes, for example:

-rw-r--r-- 1 user user 12345 file.txt

The number 12345 is the size of the file in bytes.

If you want to see the size of a directory, you can use the du command with the -sh option, which displays the size of the directory in a human-readable format:

du -sh directory

This will show the size of the directory, for example:

12M directory

The M stands for megabytes.

You can also use the stat command to display detailed information about a file, including its size:

stat file.txt

This will show output similar to the following:

File: file.txt
  Size: 12345        Blocks: 24         IO Block: 4096   regular file

The Size field shows the size of the file in bytes.

Finally, you can use the wc command to count the number of lines, words, and bytes in a file. To display just the number of bytes, you can use the -c option:

wc -c file.txt

This will show output similar to the following:

12345 file.txt

The number 12345 is the size of the file in bytes.

Created Time:2017-10-29 22:08:44  Author:lautturi