You can check the size of a file in Linux/Unix using the stat
command. The stat
command provides information about the file, including its size.
Here’s an example of how to check the size of a file named file.txt
:
stat -c %s file.txt
The -c
option specifies the format for the output, and %s
represents the size of the file in bytes.
You can also use the wc
command to check the size of a file. The wc
command stands for “word count,” but it can also display the number of bytes in a file.
Here’s an example of how to check the size of a file named file.txt
using the wc
command:
wc -c file.txt
The -c
option specifies that the wc
command should display the number of bytes in the file. The output will be in the format bytes filename
, where bytes
is the number of bytes in the file, and filename
is the name of the file.
If you want to check the size of multiple files, you can specify their names as arguments to the stat
or wc
command:
stat -c %s file1.txt file2.txt file3.txt
wc -c file1.txt file2.txt file3.txt
These commands will display the size of each file in bytes, one file per line.