LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Excluding directories with find (https://www.linuxquestions.org/questions/linux-general-1/excluding-directories-with-find-885662/)

metallica1973 06-10-2011 04:57 PM

Excluding directories with find
 
I am trying to exclude 2 directories with find and pass it into cpio. I have tried

Code:

find . -depth -path '.evolution' -prune -o -path '.gconf' -prune -o -print|cpio -aov  > /media/caca/full$date
./.gconf/apps/evolution/memos/%gconf.xml
./.gconf/apps/evolution/memos
./.gconf/apps/evolution/tasks/%gconf.xml
./.gconf/apps/evolution/tasks
./.gconf/apps/evolution/shell/view_defaults/folder_bar/%gconf.xml
./.gconf/apps/evolution/shell/view_defaults/folder_bar
./.gconf/apps/evolution/shell/view_defaults/%gconf.xml
./.gconf/apps/evolution/shell/view_defaults/10.7.X_network
./.gconf/apps/evolution/shell/view_defaults/bash_history

as you can see it didnt exclude .gconf and

Code:

find . -depth \( -path ./evolution -prune -o -path ./gconf -prune \)  -print|cpio -aov  > /media/caca/full$date
1 block

Code:

find . \( -wholename ./evolution -o -wholename ./gconf \) -prune -o -type f -print0 | cpio -aov /media/caca/backup$date
cpio: Too many arguments

Code:

find . -type d \( -name ".evolution" -o -name ".gconf" \) -prune -o -print0 | cpio -aov /media/caca/backup$date
cpio: Too many arguments

what am I doing wrong?

Snark1994 06-10-2011 05:08 PM

I don't think you need the '-depth' flag :)

Code:

find . -path './FOO' -prune -o -path './BAR' -prune -o print
works for me, and if I add '-depth' between the '.' and '-path', it doesn't.

Hope this helps,

colucix 06-10-2011 05:11 PM

Code:

find . \( -wholename ./.evolution -o -wholename ./.gconf \) -prune -o -print
Don't use the -depth option with -prune: it could change the result since the directory content is processed before the directory itself is excluded from the -prune option.

metallica1973 06-11-2011 11:28 PM

this worked

Code:

find . \( -wholename ./.evolution -o -wholename ./.gconf \) -prune -o -print
this didnt

Code:

find . -path './FOO' -prune -o -path './BAR' -prune -o print
thanks to all :cool:

Snark1994 06-13-2011 05:29 AM

Hehe, sorry, look like I left the hyphen out before 'print'. If your problem is solved, could you mark the thread '[SOLVED]' too? Thanks :)


All times are GMT -5. The time now is 07:21 AM.