[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: file/package counter



Tshepang Lekhonkhobe wrote:
Hi,
Is there any package that enables one to count the number of files in a directory(s) and/or number of packages installed on a system. Thanks...



Well to figure out how many files in a directory (not including directories and not including files in sub directories:

'find <path> -type f -maxdepth 1 | wc -l'

To find how many directories and files in a single directory (still not including sub directories)

'find <path> -maxdepth 1 | wc -l'

Both can be applied, removing the '-maxdepth 1' parameter, and checking the directory specified and all it's subdirectories.

so 'find <path> | wc -l' would tell you how many directories and files (including subdirectores and their files/directories) are present in the given path.. you get the point.

There might be better ways to do this I don't know.
Note when not using -type f, one directory will be counted as the current directory.

--K-sPecial

[ http://xzziroz.freeshell.org
  irc://xzziroz.dtdns.net       ]







Reply to: