I'm trying to count all the files from the current folder and each of it's sub-folders.
find . -type f \(! -iname ".*" \) -print
I'm trying to count all the files from the current folder and each of it's sub-folders.
find . -type f \(! -iname ".*" \) -print
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.
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.
Just pip wc -l
to it like so:
find . -type f -not -path "*/\.*" | wc -l