Solved

Calculating the used disk space with "find"

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Little introduction about CP: CP is a command on linux that use to copy files and folder from one location to another location. Example usage of CP as follow: cp /myfoder /pathto/destination/folder/ cp abc.tar.gz /pathto/destination/folder/ab…
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…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

813 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

12 Experts available now in Live!

Get 1:1 Help Now