Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Verzeichnisstruktur - aber ohne Dateien - kopieren [solved]
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) Diskussionsforum
View previous topic :: View next topic  
Author Message
slick
Bodhisattva
Bodhisattva


Joined: 20 Apr 2003
Posts: 3495

PostPosted: Wed Mar 23, 2011 8:00 am    Post subject: Verzeichnisstruktur - aber ohne Dateien - kopieren [solved] Reply with quote

Hab mal wieder was für die Shell-Spezialisten unter euch.

Ich möchte eine Verzeichnisstruktur kopieren, inkl. der Rechte/Besitzer an den Verzeichnissen, aber ohne den darin enthaltenen Dateien.

Das Ergebnis soll das gleiche sein wie nach:

Code:
cp -a /quelle /ziel
find /ziel ! -type d -exec rm {} \;


Nur in dem Fall wird erst alles kopiert und anschliessend jedes Nicht-Verzeichnis gelöscht. Jetzt suche ich die elegantere Lösung ohne die Dateien erst mit zu kopieren. Muss doch einfach gehen, ich komm nur nicht darauf.

Ein einfaches
Code:
find /quelle -type d -exec mkdir /ziel/{} \;

oder so scheidet aus, weil die Mitnahme der Verzeichnis-Rechte/Besitzer wichtig ist (kann alles sein, auch 4777 oder 1777 etc).


Last edited by slick on Wed Mar 23, 2011 11:38 am; edited 1 time in total
Back to top
View user's profile Send private message
Knieper
l33t
l33t


Joined: 10 Nov 2005
Posts: 846

PostPosted: Wed Mar 23, 2011 9:24 am    Post subject: Re: Verzeichnisstruktur - aber ohne Dateien - kopieren Reply with quote

slick wrote:
Ich möchte eine Verzeichnisstruktur kopieren, inkl. der Rechte/Besitzer an den Verzeichnissen, aber ohne den darin enthaltenen Dateien.

Mal auf die Schnelle als Ansatz: aus dem Quellverzeichnis heraus ins ../backup-Verzeichnis:
Code:
tar -c --no-recursion --files-from <(find . -type d) | sudo tar -xp -C ../backup


Funktioniert bei mir zumindest mit einem Beispiel (Symlinks, Leerzeichen etc. alles außen vor).
_________________
Je dümmer desto Gnome/KDE.
Back to top
View user's profile Send private message
slick
Bodhisattva
Bodhisattva


Joined: 20 Apr 2003
Posts: 3495

PostPosted: Wed Mar 23, 2011 11:38 am    Post subject: Reply with quote

Schöner Ansatz! Leerzeichen in Verzeichnisnamen funktionieren bei deiner Version.

Ich habe daraus mal eine Version mit rsync gebaut, die mir besser gefällt, da sich hier noch andere Optionen (wie z.B. zusätzlich Symlink / Verhalten bei Symlinks) besser steuern lassen.

(Quellverzeichnis vom rsync muss das gleiche sein wie die "Basis" von find, hier /)

Code:
rsync -lptgo / --files-from <(find /quelle -type d ; find /quelle -type l) /ziel/


solved
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Deutsches Forum (German) Diskussionsforum 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