Count number of files within a directory in Linux? [closed]

僤鯓⒐⒋嵵緔 提交于 2019-12-17 21:37:45

问题


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 ?


回答1:


this is one:

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

Note:

ls -1 | wc -l

Which means: ls: list files in dir

-1: (that's a ONE) only one entry per line. Change it to -1a if you want hidden files too

|: pipe output onto...

wc: "wordcount"

-l: count lines.



来源:https://stackoverflow.com/questions/20895290/count-number-of-files-within-a-directory-in-linux

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!