Home  >  Article  >  Operation and Maintenance  >  How to check how many files there are in linux

How to check how many files there are in linux

WBOY
WBOYOriginal
2022-05-17 10:31:1128323browse

In Linux, you can use the ls command to check how many files there are. This command is used to display the contents of the specified directory. When the parameter is set to "wc -c", the number of files in the directory can be displayed. The syntax is "ls directory path | wc -c"; you can use "sudo ls /* | wc -c" to view the number of directories on the entire computer.

How to check how many files there are in linux

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

How to check how many files there are in linux

If you want to check the number of entire directories on your computer, enter the command:

 ls /* | wc -c

If you want to check the files in a certain directory, use the Just enter the command. That is, add the directory path after [ls]. For example, the root directory here [[ls / | wc -c].

The example is as follows:

How to check how many files there are in linux

If you want to view the number of entire directories on your computer, enter the command :

sudo ls /* | wc -w

At this time, all directories on the computer will be listed.

Analysis:

ls the current directory, given to the wc command, -w means words, so this command counts the current files and folders

The example is as follows:

How to check how many files there are in linux

Recommended learning: Linux video tutorial

The above is the detailed content of How to check how many files there are 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