• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 341
  • Last Modified:

Calculating the used disk space with "find"

Hi,

on a linux machine I host an online shop. I have no idea why, but the shop software creates for every article a file "nopic_someid.jpg", each one with a different file size (don't ask me why ;) ). Now I want to calculate the wasted storage on the machine. Well, I can get all files with a normal linux "find" command, but how can I calculate the space taken by that files?
0
LL0rd
Asked:
LL0rd
  • 2
1 Solution
 
Abhishek_ChibCommented:
Him

Best way, log on via root, use following command :

find -name '*' -size +1000k | grep jpg

This will output of files name and location  which is size larger than 1000K.

Note : find command will take some time to give you output
0
 
dzhungarCommented:
There is a du (Disk usage) command in every Unix and its clones
0
 
dzhungarCommented:
Or you can use also a UNIX command df with an option -h to show human in readable format, i.e "df -h" will show you used and available space on all mounts
0
 
Alberto CortesCommented:
Next script can be useful:

total=0
find / -name "nopic_*.jpg" -print | xargs ls -la | awk '{print $5}' | while read kbytes
do
total=$( $total + $kbytes )
done
echo $total kbytes
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now