Reputation: 7245
How can I count all files, hidden files, directories, hidden directories, sub-directories, hidden sub-directories and (symbolic) links in a given directory using bash?
Upvotes: 4
Views: 266
Reputation: 131
You can also use
tree
it gives you a count in the end. I don't know how the speed compares with find. Lazily:
tree | tail -1
easier to type than find :-)
Upvotes: 0
Reputation:
find . -print0 | tr -cd '\0' | wc -c
This handles filenames with newline characters.
Upvotes: 4
Reputation: 99919
This does it:
find the_directory|wc -l
This works be finding all files in the directory, and counting them.
Upvotes: 2
Reputation: 7054
find . | wc -l
This will count each symlink as a file. To traverse symlinks, counting their contents, use:
find -L . | wc -l
Upvotes: 6