Operating System - HP-UX
1839916 Members
2498 Online
110157 Solutions
New Discussion

How to find no. of core files in /home?

 
SOLVED
Go to solution
david_252
Frequent Advisor

How to find no. of core files in /home?

Team:

I need to find out the number of core files in /home (Note only files and not directories) and also would like to know the space they occupy together. Please let me know how to do it. We have in /home lot of core directories too(for Appln. purposes and i do not need them). I just need the core files sizes and i need to know if i clear them how much space i would get.

Thanks

David.
8 REPLIES 8
Ross Zubritski
Trusted Contributor

Re: How to find no. of core files in /home?

cd /home
find . -name core

Regards,

RZ
Patrick Wallek
Honored Contributor

Re: How to find no. of core files in /home?

# cd /home
# find . -type f -name core -exec ls -ld {} \;
Ross Zubritski
Trusted Contributor

Re: How to find no. of core files in /home?

whoops, forgot the wc.
Whoops, forgot the wc

cd /home
find . -name core | wc

James R. Ferguson
Acclaimed Contributor
Solution

Re: How to find no. of core files in /home?

Hi David:

# find /home -type f -name .profile -exec ls -l {} \;|awk 'END{print SZ};{SZ=SZ+$5}'

Regards!

...JRF...
david_252
Frequent Advisor

Re: How to find no. of core files in /home?

Team:

I used JRF's method for core and it gave back the following when i run the script. could anyone tell me what this means??

3.82385e+06

I just substituted .profile with core in his script.

Thanks

David.
James R. Ferguson
Acclaimed Contributor

Re: How to find no. of core files in /home?

Hi David:

That's standard scientific notation for 3.82385 multiplied by ten to the sixth power, or 3,823,850.

If you prefer, we can format your output. Change the 'awk' protion to read:

# ... awk 'END{printf "%10d\n",SZ}; {SZ=SZ+$5}'

...this will right justify a 10-digit decimal number.

Regards!

...JRF...
Jeff Schussele
Honored Contributor

Re: How to find no. of core files in /home?

Hi David,

Try this:

find /home -type f -name core -exec ls -ld {} \; | awk '{ print $5, $9 }'

HTH,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
Adam J Markiewicz
Trusted Contributor

Re: How to find no. of core files in /home?

Hi

As you are curious how much space you will gain after deleting core files I have to add, that 'ls' command returns the _length_ of the file.

core files are so-called sparse files, in other words the have a lot of empty 'holes'. With i-node philosophy these holes are mostly not written and do not occupy any space on disk. It is possible that the long file does not occupy so much space on disk.

To check how much disk space is really used I would suggest 'du' command instead of 'ls -ld'. This command gives you the number of half-kB blocks occupied by the file instead of simple bytes.

Good luck
Adam
I do everything perfectly, except from my mistakes