[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: script using file dates

From: Bob Proulx
Subject: Re: script using file dates
Date: Thu, 6 Sep 2007 14:16:55 -0600
User-agent: Mutt/1.5.9i

marquis wrote:
> > I'm looking for an exisiting script, or a command to help w/
> > processing files by date.  I have a test website and need to
> > upload only the files that have been changed since the last
> > upload.  I'm thinking of creating a file list and the date of the
> > last upload.  if the modified date is after the date in this file,
> > it would upload.  Has anyone seen a script to do this?  i found
> > "test -nt" and "test -ot" but this is to compare two file dates,
> > not a file to a stored date.  ideas?  thanks
> TMP=`ls -Aa` ; for x in $TMP ; do echo -n "$x - " ; stat $x | tac | head -1 ;
> echo "" ; done

Hmm...  I hate to sound too critical here but I can't restrain making
comments about that command line.  It is working very much too hard to
perform the function of listing out a directory with the inode change
timestamps listed.  (And also that is not sufficient to solve the
original poster's question either.)  But back to that command line...

> TMP=`ls -Aa`

The ls -a option overrides the -A option.  Therefore 'ls -Aa' is the
same as 'ls -a'.  But you probably wanted 'ls -A' there.

> for x in $TMP ; do

Of course files with whitespace in them cause trouble here.  An extra
splitting is introduced here that will split files with whitespace

> echo -n "$x - "

Use of 'echo' with options is a portability nightmare.  Better to use
'printf' in that case.

> stat $x | tac | head -1

This is functionally the same as asking stat to output only the time
of last change directly.

  stat --format %z $x

> echo "" 

why the extra blank line?

Overall this is almost the same as using 'ls' directly.

  ls -Aclog


reply via email to

[Prev in Thread] Current Thread [Next in Thread]