LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-30-2010, 03:57 AM   #1
tomerbd
LQ Newbie
 
Registered: Sep 2003
Posts: 11

Rep: Reputation: 0
filter find and du by content of inner file in subdirectory


I have the following command that I run on cygwin:

find /cygdrive/d/tmp/* -maxdepth 0 -mtime -150 -type d | xargs du --max-depth=0 > foldersizesreport.csv

I intended to do the following with this command:

for each folder under /d/tmp/ that was modified in last 150 days, check its total size including files within it and report it to file foldersizesreport.csv
however that is now not good enough for me, as it turns out inside each

/d/tmp/subfolder1/somefile.properties
/d/tmp/subfolder2/somefile.properties
/d/tmp/subfolder3/somefile.properties
/d/tmp/subfolder4/somefile.properties

so as you see inside each subfolderX there is a file named somefile.properties
inside it there is a property SOMEPROPKEY=3808612800100 (among other properties)

this is the time in millisecond, i need to change the command so that instead of -mtime -150 it will include in the whole calculation only
subfolderX that has a file inside them somefile.properties where the SOMEPROPKEY=3808612800100 is the time in millisecond in future, if the value SOMEPROPKEY=23948948 is in past then dont at all include the folder
in the foldersizesreport.csv because its not relevant to me.

so the result report should be looking like:

/d/tmp/,subfolder1,<itssizein KB>
/d/tmp/,subfolder2,<itssizein KB>

and if subfolder3 had a SOMEPROPKEY=34243234 (time in ms in past) then it would not be in that csv file.

so basically I'm looking for:

find /cygdrive/d/tmp/* -maxdepth 0 -mtime -150 -type d | <only subfolders that have in them property in file SOMEPROPKEY=28374874827 - time in ms in future and not in past | xargs du --max-depth=0 > foldersizesreport.csv

i'm having problem how to do this, can anyone please help me with that?
thanks!!
 
Old 05-30-2010, 08:53 AM   #2
jamescondron
Member
 
Registered: Jul 2007
Location: Scunthorpe, UK
Distribution: Ubuntu 8.10; Gentoo; Debian Lenny
Posts: 961

Rep: Reputation: 69
Sometimes if you can't get it to work in a single line its because you're trying to do the wrong thing. Try scripting it out; remember one of the more important Unix maxims: find the best tool for the job.

And a single liner aint it if you're finding it this hard.
 
  


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
content filter in postfix jrafalek Linux - Software 0 04-05-2005 05:19 PM
find the same content in the file ust Linux - Newbie 5 03-23-2005 04:03 AM
Which Content Filter? jabird Linux - Networking 1 10-11-2004 07:09 PM
Internet content filter Bamse123 Linux - Software 4 12-31-2003 09:33 PM
content filter on firewall Nerun Linux - Security 3 02-21-2002 05:24 PM


All times are GMT -5. The time now is 10:06 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration