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

Re: file/package counter

Derek "The Monkey" Wueppelmann wrote:
On Tue, 2004-11-16 at 09:04, Tshepang Lekhonkhobe wrote:

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...

You could always try:

dpkg -l |wc -l

and subtrack three from that number for the three information lines at
the top. However this may not give an accurate result as you may have
some packages that are not installed on your system but have not been
purged. Perhaps:

dpkg -l | grep "^ii" |wc -l

As for the number of files in a directory. If you are just looking for
the individual directory a

ls -l | wc -l

will give you the number of files in a directory. If you wanted to
recurs and find out how many total file in a directory and all sub
directories you may need to write a short shell script to do this, or
there may be another way.

To recurse through the directory do:

ls -lR | wc -l

To include hidden files and directories in the recursive search, do:

ls -laR | wc -l


 "A short saying oft contains much wisdom." - Sophocles

Reply to: