Register
It is currently Thu Nov 27, 2014 11:33 pm

Trying to pull stat command info from dir tree files.


All times are UTC - 6 hours


Post new topic Reply to topic  [ 4 posts ] 
Author Message
 PostPosted: Fri Apr 27, 2012 10:48 am   

Joined: Wed May 19, 2010 9:56 am
Posts: 21
I am having some trouble with the syntax to get the string "Change: 2012-04-27", for example, from all the files in a tree.

Pseudo-code would be: Use grep and find on every file in the directory tree to get the output of stat that matches the string Change: 2012-04-27.

Of course grep and find are purely optional if another command provides better results.


Top
 Profile  
 PostPosted: Fri Apr 27, 2012 12:15 pm   

Joined: Wed May 19, 2010 9:56 am
Posts: 21
I guess I should clarify that I am finding all the "*.pm" files.


Top
 Profile  
 PostPosted: Fri Apr 27, 2012 1:06 pm   
User avatar

Joined: Fri Jul 22, 2011 5:39 pm
Posts: 47
Is 2012-04-27 always going to be "today's" date? or a hard coded string?

if date = today's date then,
Code:
#!/bin/bash
today=`date '+%Y-%m-%d'`
find . -iname "*.pm" -exec stat {} \;  | grep Change | grep "$today"


That's all I got.

HTH. or get's you on your way to a solution.


Top
 Profile WWW  
 PostPosted: Fri Apr 27, 2012 7:20 pm   

Joined: Mon Mar 02, 2009 3:03 am
Posts: 571
read closer find's man page, there's an 'option/command' -printf which is able to output this data.


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], Seiduna and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP