Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Verzeichnisbaum löschen, mit Ausnahme
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

 
Reply to topic    Gentoo Forums Forum Index Deutsches Forum (German)
View previous topic :: View next topic  
Author Message
AntonWert
Apprentice
Apprentice


Joined: 06 Mar 2005
Posts: 177

PostPosted: Mon Nov 14, 2005 6:01 pm    Post subject: Verzeichnisbaum löschen, mit Ausnahme Reply with quote

Wie der Titel schon sagt, ich will einen kompletten Verzeichnisbaum löschen (z.B. /usr/portage/) - was ja rekursiv geht - aber dabei z.B. die Distfiles in /usr/portage/distfiles behalten, wie mach ich das?
Back to top
View user's profile Send private message
theche
Guru
Guru


Joined: 26 Feb 2004
Posts: 512

PostPosted: Mon Nov 14, 2005 6:14 pm    Post subject: Reply with quote

mv sie vorher woanders hin. und dann wieder zurück. :roll:
Back to top
View user's profile Send private message
hoernerfranz
Tux's lil' helper
Tux's lil' helper


Joined: 29 Feb 2004
Posts: 135
Location: Baden

PostPosted: Mon Nov 14, 2005 6:36 pm    Post subject: Reply with quote

oder so:

Code:

cd /usr
find portage -type d -maxdepth 1 | grep "/" | grep -v distfiles | xargs ls -ld


die ausgabe zeigt dir dann was gelöscht würde, wenn du 'ls -ld' am schluss durch
'rm -rf' ersetzt.
ohne gewähr. :D
Back to top
View user's profile Send private message
SinoTech
Advocate
Advocate


Joined: 20 Mar 2004
Posts: 2579
Location: Neunkirchen / Saarland / Germany

PostPosted: Mon Nov 14, 2005 7:29 pm    Post subject: Reply with quote

hoernerfranz wrote:
oder so:

Code:

cd /usr
find portage -type d -maxdepth 1 | grep "/" | grep -v distfiles | xargs ls -ld


die ausgabe zeigt dir dann was gelöscht würde, wenn du 'ls -ld' am schluss durch
'rm -rf' ersetzt.
ohne gewähr. :D

Also wenn "find", dann doch so:
Code:

$ find /usr/portage -maxdepth 1 ! -name "distfiles" -exec rm -rf {} \;


Mfg

Sino
Back to top
View user's profile Send private message
hoernerfranz
Tux's lil' helper
Tux's lil' helper


Joined: 29 Feb 2004
Posts: 135
Location: Baden

PostPosted: Mon Nov 14, 2005 7:57 pm    Post subject: Reply with quote

Code:

$ find /usr/portage -maxdepth 1 ! -name "distfiles" -exec rm -rf {} \;


mach das ruhig mal.
da haste dann /usr/portage selber als argument f. -exec ....
Back to top
View user's profile Send private message
SinoTech
Advocate
Advocate


Joined: 20 Mar 2004
Posts: 2579
Location: Neunkirchen / Saarland / Germany

PostPosted: Mon Nov 14, 2005 9:02 pm    Post subject: Reply with quote

hoernerfranz wrote:
Code:

$ find /usr/portage -maxdepth 1 ! -name "distfiles" -exec rm -rf {} \;


mach das ruhig mal.
da haste dann /usr/portage selber als argument f. -exec ....

Hast Reht .. dann klemmen wir halt noch ein "-mindepth" rein :D
Code:

$ find /usr/portage/ -mindepth 1 -maxdepth 1 ! -name "distfiles" -exec rm -rf {} \;

Naja, die schönste Lösung ist das mit Sicherheit nicht, aber würde funktionieren.

Mfg

Sino
Back to top
View user's profile Send private message
Earthwings
Bodhisattva
Bodhisattva


Joined: 14 Apr 2003
Posts: 7753
Location: Germany

PostPosted: Mon Nov 14, 2005 11:03 pm    Post subject: Reply with quote

SinoTech wrote:
hoernerfranz wrote:
Code:

$ find /usr/portage -maxdepth 1 ! -name "distfiles" -exec rm -rf {} \;


mach das ruhig mal.
da haste dann /usr/portage selber als argument f. -exec ....

Hast Reht .. dann klemmen wir halt noch ein "-mindepth" rein :D
Code:

$ find /usr/portage/ -mindepth 1 -maxdepth 1 ! -name "distfiles" -exec rm -rf {} \;

Naja, die schönste Lösung ist das mit Sicherheit nicht, aber würde funktionieren.

Sicher? Was ist mit evtl. Unterordnern von distfiles, bleiben die erhalten? Und was wäre, wenn distfiles kein direkter Unterordner von /usr/portage wäre?
_________________
KDE
Back to top
View user's profile Send private message
hoernerfranz
Tux's lil' helper
Tux's lil' helper


Joined: 29 Feb 2004
Posts: 135
Location: Baden

PostPosted: Tue Nov 15, 2005 7:13 am    Post subject: Reply with quote

Earthwings wrote:

Sicher? Was ist mit evtl. Unterordnern von distfiles, bleiben die erhalten?


klar, das ist ja der sinn der sache :D
der 'trick' besteht darin, nur die ordner in der ebene unter /usr/portage (mittels maxdepth) als argumente an -exec zu geben, ohne distfiles.
damit wird dieser ordner samt unterordnern ignoriert, die anderen aber rekursiv gelöscht.

Quote:

Und was wäre, wenn distfiles kein direkter Unterordner von /usr/portage wäre?


dann müsste man es anders machen ...
Back to top
View user's profile Send private message
Fauli
l33t
l33t


Joined: 24 Apr 2004
Posts: 760
Location: Moers, Germany

PostPosted: Wed Nov 16, 2005 7:30 pm    Post subject: Reply with quote

Oder einfach so:
Code:
rm -r /usr/portage/!(distfiles)

_________________
Do your part to beautify the web! Turn off link underlining!
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Deutsches Forum (German) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum