Matthew Edlefsen on 15 Jan 2010 06:23:38 -0800


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

Re: [PLUG] find, xargs, tar and ssh or selectively backing up some files on another server


On Fri, Jan 15, 2010 at 9:15 AM, E. M. Recio <erecio@polywog.org> wrote:
> On Thursday 17 December 2009 14:44:55 Kevin McAllister wrote:
>> On Dec 17, 2009, at 12:58 PM, Matthew Edlefsen wrote:
>> > find voicemail/*/*/INBOX -type f -mtime +180 -print | tar -cT - | ssh ...
>> >
>> > should work
>> >
>> > -T FILE tells tar to read a list of files to tar from FILE.
>
> How do you tell find to exclude a list of files or a pattern. For example, I
> want to list files under foo/ but exclude all files in directories and
> subdirectories called .bar and execute a command on each file
>
> ./foo/a/b
> ./foo/a/.bar/e
> ./foo/a/.bar/f
> ./foo/a/g/e
> ./foo/a/g/.bar/h
> ./foo/a/g/.bar/i
> ./foo/c/d
>
> Currnently, I use
>
> for i in `find ./ -type f | grep -v ".bar"`; do MyCommand.sh $i; done
>
> But there should be a way I can do
>
> find ./ -type f XXXXX -exec MyCommand.sh \{\} \;
>
> Where XXXXX would be the exclude option.
>
> -elmo

find has a full set of logical ops: -and, -or, -not, and \( \)

no relational op between tests defaults to -and

find . -type f -and -not -path '*/.bar/*'
___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug