1

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

find . -type f \(! -iname ".*" \) -print
Inian
  • 80,270
  • 14
  • 142
  • 161
Jonathan
  • 53
  • 1
  • 8
  • 2
    [What should I do when someone answers my question?](https://stackoverflow.com/help/someone-answers) – KamilCuk Oct 03 '18 at 08:56
  • Possible duplicate of [How to count all files inside a folder, its subfolder and all . The count should not include folder count](https://stackoverflow.com/q/9769434/608639) – jww Oct 03 '18 at 21:34

3 Answers3

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.

oliv
  • 12,690
  • 25
  • 45
0

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.

mstruebing
  • 1,674
  • 1
  • 16
  • 29
-1

Just pip wc -l to it like so:

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

AHT
  • 404
  • 1
  • 3
  • 17