Count files, except the hidden files [duplicate]

眉间皱痕 提交于 2021-02-10 17:33:24

问题


I'm trying to count all the files from the current folder and each of it's sub-folders.

find . -type f \(! -iname ".*" \) -print

回答1:


You can use this find command:

find -type f ! -regex ".*/\.[^/]+$"  | wc -l

It will find all files in the current directory with filename not starting with a ., aka hidden files.




回答2:


find . -type f -not -path "./.*" | wc -l

explanation:

find in the current directory(.) all things from type file(f) which does not have a path that starts with ./.(./ is prepend on every output item of find which means current directory) and then give the output to wc which is a program to count and the -l parameter tells wc to count lines.




回答3:


Just pip wc -l to it like so:

find . -type f -not -path "*/\.*" | wc -l



来源:https://stackoverflow.com/questions/52621332/count-files-except-the-hidden-files

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