简体   繁体   English

如何计算linux中的文件夹数量?

[英]how to count the number of folders in linux?

How to count the number of directories on the desktop?如何统计桌面上的目录数? I get only a list of folders, but I need only the number of folders and I absolutely don't understand how to do it!我只得到一个文件夹列表,但我只需要文件夹的数量,我绝对不明白该怎么做! :( :(

PS NOT files, ONLY folders PS 不是文件,只有文件夹

thank you!谢谢你!

try:尝试:

ls -d ./* |wc

ls -d ./* should give you a list of directories and wc Count it ls -d ./*应该给你一个目录列表和wc计数它

Use wc to count the lines of output after getting the list of folders would be one option.获取文件夹列表后使用wc计算输出行数将是一种选择。 Assuming your operation outputs one line per folder.假设您的操作为每个文件夹输出一行。 As an example: cat myfile.txt | wc -l例如: cat myfile.txt | wc -l cat myfile.txt | wc -l

In order to only find the folders you could use something like find in a fashion like this: find . -type d为了只找到你可以使用类似的文件夹find在这样的方式: find . -type d find . -type d

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM