Solved

Calculating the used disk space with "find"

Posted on 2011-03-16
4
324 Views
Last Modified: 2012-05-11
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
Comment
Question by:LL0rd
  • 2
4 Comments
 
LVL 3

Expert Comment

by:Abhishek_Chib
ID: 35153477
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
 
LVL 1

Expert Comment

by:dzhungar
ID: 35153522
There is a du (Disk usage) command in every Unix and its clones
0
 
LVL 1

Expert Comment

by:dzhungar
ID: 35153538
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
 
LVL 3

Accepted Solution

by:
Alberto Cortes earned 500 total points
ID: 35153559
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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now