计算Linux目录中文件的数量? [关闭]

本文翻译自:Count number of files within a directory in Linux? [closed]

To count the number of files in a directory, I typically use 为了计算目录中的文件数,我通常使用

ls directory | wc -l

But is there another command that doesn't use wc ? 但是还有另一个不使用wc命令吗?


#1楼

参考:https://stackoom.com/question/1pFOO/计算Linux目录中文件的数量-关闭


#2楼

this is one: 这是一:

ls -l . | egrep -c '^-'

Note: 注意:

ls -1 | wc -l

Which means: ls: list files in dir 这意味着: ls:列出dir中的文件

-1: (that's a ONE) only one entry per line. -1:即ONE)每行只有一个条目。 Change it to -1a if you want hidden files too 如果您也想要隐藏文件,请将其更改为-1a

| : | : pipe output onto... | :管道输出到...

wc: "wordcount" wc: “ wordcount”

-l: count l ines. -l:计数l分级表。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值