[TriLUG] Some script help

William Sutton via TriLUG trilug at trilug.org
Tue May 12 17:14:02 EDT 2015


I have used mtime in the past, but sometimes I have also changed something 
on a dated file (maybe gzip'd it, for example) such that the mtime no 
longer reflects the actual date of the file.

That's why my suggestion perserved the date from his filename, rather than 
relying on the mtime (or ctime, or atime).

William Sutton

On Tue, 12 May 2015, Matt Pusateri via TriLUG wrote:

> A lot simpler to just have find +mtime script prune the directory and rsync to transfer the files as someone else alluded to
>
> Matt 
>
> Sent from my iPhone
>
>> On May 12, 2015, at 4:40 PM, Alan Porter via TriLUG <trilug at trilug.org> wrote:
>> 
>> 
>> 
>> 
>>> Bash is fine for this, but the key is to not try to compare dates. Bash doesn't do that well at all.
>> 
>> If you must compare dates in bash, let the date command convert them for you.
>> 
>> echo $((  (  $(date -d '2015-05-12' +%s)  -  $(date -d '2014-05-12' +%s)  )  / 86400  ))
>> 365
>> 
>> 
>> Or if long lines are not your thing...
>> 
>> d1=$(date -d '2015-05-12' +%s)
>> d2=$(date -d '2014-05-12' +%s)
>> echo $(( ( $d1 -  $d2 ) / 86400 ))
>> 365
>> 
>> 
>> Alan
>> 
>> 
>> 
>> -- 
>> This message was sent to: M. Pusateri <mpusateri at wickedtrails.com>
>> To unsubscribe, send a blank message to trilug-leave at trilug.org from that address.
>> TriLUG mailing list : http://www.trilug.org/mailman/listinfo/trilug
>> Unsubscribe or edit options on the web    : http://www.trilug.org/mailman/options/trilug/mpusateri%40wickedtrails.com
>> Welcome to TriLUG: http://trilug.org/welcome
> -- 
> This message was sent to: William <william at trilug.org>
> To unsubscribe, send a blank message to trilug-leave at trilug.org from that address.
> TriLUG mailing list : http://www.trilug.org/mailman/listinfo/trilug
> Unsubscribe or edit options on the web	: http://www.trilug.org/mailman/options/trilug/william%40trilug.org
> Welcome to TriLUG: http://trilug.org/welcome


More information about the TriLUG mailing list