This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Advice on where to look to solve a problem


Steve wrote:

> I need to make a script that will check all of the file modified dates
> on all of the files in a list of directories.   If any of these dates is
> older then the current date I want to print the name of the file and the
> date to a file.
> 
> I'm new to bash scripting and many unix commands.  What are the commands
> that I want to loook at that could do these things for me?

I think the find command should be able to do what you want.  For
example "find . -mtime +1" should give you a list of files that are
older than 24 hours (based on modification date.)  You didn't say
exactly what you meant by "older than the current date" but you may also
be able to use -daystart if you want files not modified today, rather
than in the last 24 hours.  

For printing the names, you can use "-ls" to give a rather verbose
listing, or append "| xargs ls -l" to get an "ls -l" listing for each
find result... you may want to read the other thread about doing ls -l
on find results, either add "-type f" or use "ls -ld" otherwise you'll
list contents of directories rather then their names.  You can also use
"-printf" and specify whatever output format you want.

Brian

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]