Solved

Calculating the used disk space with "find"

Posted on 2011-03-16
4
321 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Using 'screen' for session sharing, The Simple Edition Step 1: user starts session with command: screen Step 2: other user (logged in with same user account) connects with command: screen -x Done. Both users are connected to the same CLI sessio…
It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
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…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

759 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

22 Experts available now in Live!

Get 1:1 Help Now