How to check file size in linux

青灯夜游
青灯夜游Original
2020-12-29 15:11:3259058browse

How to check the file size in Linux: 1. Use the "stat file name" command to display detailed information of the specified file to view the file size; 2. Use the "wc -c file name" command to view; 3 , use the "du -h file name" command to view; 4. Use the "ls -l file name" command to view.

How to check file size in linux

The operating environment of this tutorial: red hat enterprise linux 6.1, Dell G3 computer.

1. stat command

stat command: Display detailed information of the file/file system.

The stat command is mainly used to display detailed information of a file or file system. The syntax format of this command is as follows:

-f: does not display the information of the file itself, but displays the information of the file system where the file is located.

-L: Display symbolic links

-t: Simple mode, only display summary information

stat ljl.txt

How to check file size in linux

2. wc Command

wc command is used to calculate numbers. We can use the wc command to calculate the number of Bytes, words, or columns of a file. If the file name is not specified, or the file name is given as "-", the wc command will read data from the standard input device.

wc -c filename parameter -c represents statistical characters, because one character is one byte, so the number of bytes is obtained

wc -c ljl.txt

How to check file size in linux

three , du command

du command also checks the space used, but unlike the df command, the Linux du command checks the space used by files and directory disks, which is somewhat different from the df command. .

du -b filepath parameter -b indicates counting in bytes

du -b ljl.txt

How to check file size in linux
or
du -h filepath directly obtains the file size recognized by people

du -h ljl.txt

How to check file size in linux

4. ls command

The ls command is used to display the target list and is a highly used command in Linux. The output information of the ls command can be displayed with color highlighting to partition different types of files.

ls -l filepath The fifth column is the number of bytes in the file

ls -l ljl.txt

How to check file size in linux
ls -h filepath h means human, add the -h parameter to get the file size that is easy for humans to read

ls -lh ljl.txt

How to check file size in linux

Related recommendations: "Linux Video Tutorial"

The above is the detailed content of How to check file size in linux. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn