Come posso trovare tutti i file e tutte le directory corrispondenti a un modello, escludendo una directory usando find?
Supponiamo che io abbia la seguente struttura di file;
.
foo-esclusione-me /
foo.txt
foo-esclusione-me-not /
foo.txt
bar/
foo.txt
foobar /
bar.txt
foofoo.txt
come otterrei il seguente output usando find:
./bar/foo.txt ./bar/foobar ./bar/foobar/foofoo.txt ./foo-exclude-me-not ./foo-exclude-me-not/foo.txt
Ho provato a utilizzare entrambi i seguenti comandi:
trova . -name 'foo-exclude-me' -prune -o -name 'foo *' trova . -name 'foo *' \! -path './foo-exclude-me/*'
ma entrambi restituiscono questo:
./bar/foo.txt
./bar/foobar
./bar/foobar/foofoo.txt
./foo-exclude-me # << this should be excluded
./foo-exclude-me-not
./foo-exclude-me-not/foo.txt
Come posso escludere correttamente la foo-exclude-medirectory?
-printe foo-exclude-meinvece di ./foo-exclude-me.
foo-exclude-meinvece di./foo-exclude-me. Prova anche ad aggiungere-printalla fine del comando.