Andy Smith wrote:
> On Mon, May 21, 2007 at 04:04:58PM +0100, Brian Chivers wrote:
>> Andy Smith wrote:
>>> Hi Brian,
>>>
>>> On Mon, May 21, 2007 at 11:25:07AM +0100, Brian Chivers wrote:
>>>> 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.
>>> Does what I suggested in:
>>>
>>>        http://www.hants.lug.org.uk/lurker/message/20070508.120756.ee622777.en.html
>>>
>>> not work?
>>>
>> Not tried it yet, trying to get my mind round what each of the bits does.
> 
> Okay,
> 
> find /path -type f -atime +365 -print0 | xargs -0 tar pcf - | (cd /target && tar pxvf -) 
> 
> find /path -type f -atime +365
> 
>         Find files whose last *access time* was more than 365 days
>         ago.  If you prefer to use your mtime rule as before then do
>         that instead.  -atime's not going to work if the filesystem
>         is munted noatime, either.
> 
> -print0
> 
>         Print the names of the above files delimited by ascii NUL
>         characters.  This allows the filenames/paths to contain
>         anything, so solves your problem of things like spaces,
>         brackets, or other shell metacharacters.
> 
> | xargs -0
> 
>         Pipe that list of paths through xargs -0, which takes a list
>         of NUL-separated things and passes them to a command..
> 
> tar pcf -
> 
>         The tar command will compress (-c) the list of files it gets
>         from xargs, preserving permissions (-p), and it will write
>         out a tar archive to its standard output (-f -).
> 
> | (cd /target && tar pxvf -)
> 
>         The standard output of the previous tar gets piped through
>         this subshell, which changes directory to your target, and
>         runs another tar to extract (-x) its standard input (-f -)
>         verbosely (-v) preserving permissions (-p).
> 
>         Could probably also be done as just:
> 
>                 tar -C /target pxvf -
> 
>         but I'm set in my ways..
> 
> Hope that makes more sense.
> 
> Cheers,
> Andy
> 
> 
Thanks for explaining it in nice simple terms, the bit that was confusing me was the double tar bit 
but now it makes sense.
Brian
------------------------------------------------------------------------------------------------
    The views expressed here are my own and not necessarily
 
                the views of Portsmouth College