LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
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.

Notices



Reply
 
Search this Thread
Old 07-01-2005, 03:16 AM   #1
fireman949
Member
 
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:
Code:
find /home/httpd/vhosts/*/httpdocs/userfiles -ctime +30 -daystart -exec /usr/bin/du -sh '{}' \;
and
Code:
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
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,005
Blog Entries: 11

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
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:
Code:
find  -ctime +30 -daystart -type d | xargs du -b 2>/dev/null | awk '{total += $1; print $0} END{print total}'

Cheers,
Tink
 
Old 07-10-2005, 02:42 AM   #3
fireman949
Member
 
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.
 
  


Reply


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


All times are GMT -5. The time now is 07:17 PM.

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