Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 07-01-2005, 03:16 AM   #1
Registered: Dec 2003
Location: Walls
Distribution: Slackware 10.1;CentOS 4
Posts: 51

Rep: Reputation: 15
du on specific files from find command (use xargs?)

Typically when you execute 'du -h' you get a listing of all the files in the directory and subdirectories and a total usage at the bottom. I am trying to get the total usage from all the files in several directories. I have tried the following:
find /home/httpd/vhosts/*/httpdocs/userfiles -ctime +30 -daystart -exec /usr/bin/du -sh '{}' \;
find /home/httpd/vhosts/*/httpdocs/userfiles -ctime +30 -daystart -type d | xargs du -sh | sort -n
Both return virtually the same thing, but no total at the bottom. What I'm trying to accomplish is to give someone an idea of how much space will be cleared up by deleting all the files older than 30 days before I use -exec rm'{} \; with find.
Old 07-01-2005, 04:16 AM   #2
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917
Neither will work, both exec and xargs will ALWAYS only operate
on the individual arguments, thus won't give you a total ...

What you should be looking at is something like:
find  -ctime +30 -daystart -type d | xargs du -b 2>/dev/null | awk '{total += $1; print $0} END{print total}'

Old 07-10-2005, 02:42 AM   #3
Registered: Dec 2003
Location: Walls
Distribution: Slackware 10.1;CentOS 4
Posts: 51

Original Poster
Rep: Reputation: 15
Thanks Tink.

I'm getting a number like 2.61811e+11, which if I had paid more attention in college I'm sure I'd know how to convert this.

Your solution did work, thank you.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to find files containing specific text? SurfTurtle Linux - Newbie 7 01-05-2008 06:57 AM
copying files and give new unique names to each file by using xargs command gnim66 Programming 6 06-22-2005 09:29 PM
Command line tools to Find files with specific text naps Linux - Software 5 11-15-2004 05:46 AM
how to find a specific file over several *.tgz files eeyoree Slackware 6 08-09-2004 01:37 AM
Find files, directories that are own by specific user mikeshn Linux - General 2 02-12-2004 04:52 PM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 07:59 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration