Home > Operation and Maintenance > Linux Operation and Maintenance > How to check file size in linux

How to check file size in linux

coldplay.xixi
Release: 2023-01-03 09:29:53
Original
54396 people have browsed it

How to check the file size in Linux: 1. Use the stat command to view the detailed information display of the file system; 2. Use the wc command to calculate the number of Bytes of the file, etc.; 3. Use the du command to view the used space; 4. The ls command is used to display a list of targets.

How to check file size in linux

The operating environment of this tutorial: linux7.3 system, DELL G3 computer.

How to check the file size in Linux:

1. stat command

stat command: details of file/file system the message says.

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
Copy after login

2. wc command

wc command 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
Copy after login

3. du command

The 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 The parameter -b indicates counting in bytes

du -b ljl.txt
Copy after login

or

du -h filepath directly obtains the file size that people can recognize

du -h ljl.txt
Copy after login

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 file bytes

ls -l ljl.txt
Copy after login

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
Copy after login

Related learning 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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template