Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Calculating the used disk space with "find"

Posted on 2011-03-16
4
Medium Priority
?
338 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 2000 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

New Tabletop Appliances Blow Competitors Away!

WatchGuard’s new T15, T35 and T55 tabletop UTMs provide the highest-performing security inspection in their class, allowing users at small offices, home offices and distributed enterprises to experience blazing-fast Internet speeds without sacrificing enterprise-grade security.

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…
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
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…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Suggested Courses
Course of the Month12 days, 16 hours left to enroll

971 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