delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2003/07/08/11:05:33

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Message-ID: <3F0ADDAE.62AA803D@dessent.net>
Date: Tue, 08 Jul 2003 08:05:18 -0700
From: Brian Dessent <brian AT dessent DOT net>
Organization: My own little world...
X-Accept-Language: en,en-US
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: Advice on where to look to solve a problem
References: <beekii$5sc$1 AT main DOT gmane DOT org>

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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019