1755577 Members
3746 Online
108836 Solutions
New Discussion юеВ

file count

 
SOLVED
Go to solution

file count

Is there a way to count all the files on a server (HP-UX 10.20) other than using find?
10 REPLIES 10
Kofi ARTHIABAH
Honored Contributor

Re: file count

how about
du / -a | wc -l
nothing wrong with me that a few lines of code cannot fix!
Stefan Farrelly
Honored Contributor

Re: file count


ls -R | wc -l
Im from Palmerston North, New Zealand, but somehow ended up in London...
Andreas Voss
Honored Contributor

Re: file count

Hi,

to avoid for du walking thru NFS use:

du -t hfs -t vxfs -a / | wc -l

Regards
CHRIS ANORUO
Honored Contributor

Re: file count

Use ls -aR /|wc -l
When We Seek To Discover The Best In Others, We Somehow Bring Out The Best In Ourselves.
John Palmer
Honored Contributor

Re: file count

What is it that you are actually trying to achieve?

The previous replies are good if you just want to find how many files and directories exist.
Andy Monks
Honored Contributor
Solution

Re: file count

The quickest way is probably :-

bdf -i

Then just look at the iused column. Each file and directory requires 1 inode.
RikTytgat
Honored Contributor

Re: file count

Hi,

Andy's solution is indeed the best and the quickest.

To calculate the total number of files on all mounted file systems:

-------------------
total_files=0
set $(bdf -i)
shift 10
while [ $# -gt 1 ]
do
let total_files=$total_files+$6
shift 9
done
print $total_files
----------------------


Hope this helps,
Rik.
P V Patel
Advisor

Re: file count

Hi,
TO count total number of files on all mounted local file systems run following script:

total_files=0
for number in `bdf -il | grep -v Filesystem | awk '{print $6}'`
do
total_files=`expr $total_files + $number`
done
echo $total_files
Regards.
Punjabhai V Patel
Punjabhai
Anthony Goonetilleke
Esteemed Contributor

Re: file count

Just the for the fun of it you could also do

find / | wc -l

reember though in most of the methods you will be counting . and ..
But in find you could do somthing like
find . | grep -v ". " | grep -v ".. " | wc -l

and if you didnt want nfs dir's you can add this as an option to find
Minimum effort maximum output!