Re: [Hampshire] Finding files not used in the last 365 days …

Top Page

Reply to this message
Author: Brian Chivers
Date:  
To: Hampshire LUG Discussion List
Old-Topics: Re: [Hampshire] Finding files not used in the last 365 days
Subject: Re: [Hampshire] Finding files not used in the last 365 days - A different idea using tar
Simon Reap wrote:
> On 08/05/07 14:58, Hugo Mills said the following:
>>    Then something like this would work (but would create more
>> directories than may be necessary):

>>
>> $ cd /home/admin/Marketing
>> $ find -type d -print0 | xargs -0 mkdir -p
>> $ find -type f -mtime 365 -exec mv "{}" "/mount/achieve/Marketing/{}"
>>
>>    Hugo.

>>
>>
>
> Or, combining the read/exec versions, to reduce the number of
> directories created:
>
> $ cd /home/admin/Marketing
> $ find . -type f -mtime 365 | while read nam
> do
>  namdir=$(dirname "$nam")
>  if [ ! -d "$namdir" ]
>  then
>     mkdir -p "$namdir"
>  fi
>  mv "$nam" /mount/archive/marketing/"$nam"
> done

>
>
>
>
>
> This e-mail and any attachment is for authorised use by the intended
> recipient(s) only. It may contain proprietary material, confidential
> information and/or be subject to legal privilege. It should not be
> copied, disclosed to, retained or used by, any other party. If you are
> not an intended recipient then please promptly delete this e-mail and
> any attachment and all copies and inform the sender. Thank you.
>


I've been playing with all the options and it would appear that the user who has created the files
likes to use STUPID characters like brackets in her filenames :-/ and this is causing the script to
error out at random points so I've been having a rethink.

Could I use tar with the --after-date option, so use a line like

tar -zcvf --after-date=DATE marketing.tgz /home/Marketing/

The thing is I'm not sure what format the date should be in ?

Then when I know that this file has worked OK I could move the tgz file to the other server and
extract it recreating all the files and directories and then finally delete all the files on the
main server.

Any Thoughts on this
Thanks
Brian

------------------------------------------------------------------------------------------------
    The views expressed here are my own and not necessarily


                the views of Portsmouth College