LINUX.IE, website of the Irish Linux Users' Group
Tux rules!

   
Home
New Users
Articles
Download
Projects
Community
Vendors

  Print Version
Email to...
 
Archives:


planetILUG

Recent News

News Archive


Join the
ILUG
on FaceBook


Join the
ILUG
on LinkedIn


Join the
ILUG SETI
Group



















 
 :: Mailing Lists

[ILUG] find syntax question

[ILUG] find syntax question

P at draigBrady.com P at draigBrady.com
Wed Feb 4 12:14:39 GMT 2004


P at draigBrady.com wrote:
> Justin MacCarthy wrote:
> 
>>
>> What is the syntax for "modified in month mm, year yyyy" in find
>> e.g. the -mtime syntax
> 
> 
> Hmm, I'm not sure there is a direct way.
> You could try the following (untested) script

OK tested (you may want to check files on the first
and last days of the month are caught correctly):

#!/bin/sh

month=$1
year=$2
if [ "$month" = "12" ]; then
     next_year=`expr $year + 1`
     next_month=1
else
     next_year=$year
     next_month=`expr $month + 1`
fi
now=`date +%s`
start=`date --date="$year-$month-01 UTC" +%s`
end=`date --date="$next_year-$next_month-01 UTC" +%s`
start_days_ago=`expr \( $now - $start \) / 86400`
end_days_ago=`expr \( $now - $end \) / 86400`
find -mtime -$start_days_ago -mtime +$end_days_ago -maxdepth 1

-- 
Pádraig Brady - http://www.pixelbeat.org
--- Following generated by rotagator ---

Quickly search word list for prefix
   look prefix
Highlight occurances of word in word list
   grep --color word /usr/share/dict/words
Lookup word in online dictionaries/info
   gnome-dictionary ireland
--




More information about the ILUG mailing list
Read this without the formatting.
                                                                                                    

 

Hosted by HEAnet


Maintained by the ILUG website team. The aim of Linux.ie is to support and help commercial and private users of Linux in Ireland. You can display ILUG news in your own webpages, read backend information to find out how. Networking services kindly provided by HEAnet, server kindly donated by Dell. Linux is a trademark of Linus Torvalds, used with permission. No penguins were harmed in the production or maintenance of this highly praised website. Looking for the Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!
RSS Version
Powered by Dell