sruggiero
25.02.09, 09:29
Hallo,
ich möchte in einem Skript einen großen Verzeichnisbaum parsen, dazu muss ich aus dem Baum eine Liste mit den Pfaden zu allen "tiefsten" Verzeichnissen erstellen. D.h. ich brauchen einen Befehl, der in den Baum einsteigt und in das erste Unterverzeichnis geht, dort wieder das nächste Unterverzeichnis usw. bis kein Unterverzeichnis mehr kommt und dann den vollständigen Pfad zum letzten Unterverzeichnis ausgibt.
Dann geht es ein Verzeichnis hoch und in das nächste Unterverzeichnis rein, dort dann das gleiche Spiel.
Dabei kann ich vorher nicht wissen, wie tief jeder Teilbaum ist.
Zur Veranschaulichung:
Dieser Baum:
root
---Dir1
--- ---Subdir1ofDir1
--- --- ---DirA
--- --- --- ---File1
--- --- --- ---File2
--- --- --- ---File3
--- --- ---DirB
--- --- --- ---File1
--- --- --- ---File2
--- --- --- ---File3
--- ---Subdir2ofDir1
--- --- ---DirC
--- --- --- ---File1
--- --- --- ---File2
--- --- --- ---File3
--- ---Subdir3ofDir1
--- --- ---DirD
--- --- --- ---File1
--- --- --- ---File2
--- --- --- ---File3
--- --- ---DirE
--- --- --- ---File1
--- --- --- ---File2
--- --- --- ---File3
---Dir2
--- ---Subdir1ofDir2
--- --- ---DirF
--- --- --- ---File1
--- --- --- ---File2
--- --- --- ---File3
--- --- ---DirG
--- --- --- ---File1
--- --- --- ---File2
--- --- --- ---File3
--- ---Subdir2ofDir2
--- --- ---DirH
--- --- --- ---File1
--- --- --- ---File2
--- --- --- ---File3
--- --- ---DirI
--- --- --- ---File1
--- --- --- ---File2
--- --- --- ---File3
soll aufgelöst werden in diese Liste:
/Dir1/Subdir1ofDir1/DirA
/Dir1/Subdir1ofDir1/DirB
/Dir1/Subdir2ofDir1/DirC
/Dir1/Subdir3ofDir1/DirD
/Dir1/Subdir3ofDir1/DirE
/Dir2/Subdir1ofDir2/DirF
/Dir2/Subdir1ofDir2/DirG
/Dir2/Subdir2ofDir2/DirH
/Dir2/Subdir2ofDir2/DirI
der "find"-Befehl gibt mir immer auch alle "Zwischenverzeichnisse" aus, die Liste sieht dann so aus:
find <root> -type d
/
/Dir1
/Dir1/Subdir1ofDir1
/Dir1/Subdir1ofDir1/DirA
/Dir1/Subdir1ofDir1/DirB
/Dir1/Subdir2ofDir1
/Dir1/Subdir2ofDir1/DirC
/Dir1/Subdir3ofDir1
/Dir1/Subdir3ofDir1/DirD
/Dir1/Subdir3ofDir1/DirE
/Dir2
/Dir2/Subdir1ofDir2
/Dir2/Subdir1ofDir2/DirF
/Dir2/Subdir1ofDir2/DirG
/Dir2/Subdir2ofDir2
/Dir2/Subdir2ofDir2/DirH
/Dir2/Subdir2ofDir2/DirI
Kann mir da jemand helfen?
Vielen Dank!
Schönen Gruss,
Stephan
ich möchte in einem Skript einen großen Verzeichnisbaum parsen, dazu muss ich aus dem Baum eine Liste mit den Pfaden zu allen "tiefsten" Verzeichnissen erstellen. D.h. ich brauchen einen Befehl, der in den Baum einsteigt und in das erste Unterverzeichnis geht, dort wieder das nächste Unterverzeichnis usw. bis kein Unterverzeichnis mehr kommt und dann den vollständigen Pfad zum letzten Unterverzeichnis ausgibt.
Dann geht es ein Verzeichnis hoch und in das nächste Unterverzeichnis rein, dort dann das gleiche Spiel.
Dabei kann ich vorher nicht wissen, wie tief jeder Teilbaum ist.
Zur Veranschaulichung:
Dieser Baum:
root
---Dir1
--- ---Subdir1ofDir1
--- --- ---DirA
--- --- --- ---File1
--- --- --- ---File2
--- --- --- ---File3
--- --- ---DirB
--- --- --- ---File1
--- --- --- ---File2
--- --- --- ---File3
--- ---Subdir2ofDir1
--- --- ---DirC
--- --- --- ---File1
--- --- --- ---File2
--- --- --- ---File3
--- ---Subdir3ofDir1
--- --- ---DirD
--- --- --- ---File1
--- --- --- ---File2
--- --- --- ---File3
--- --- ---DirE
--- --- --- ---File1
--- --- --- ---File2
--- --- --- ---File3
---Dir2
--- ---Subdir1ofDir2
--- --- ---DirF
--- --- --- ---File1
--- --- --- ---File2
--- --- --- ---File3
--- --- ---DirG
--- --- --- ---File1
--- --- --- ---File2
--- --- --- ---File3
--- ---Subdir2ofDir2
--- --- ---DirH
--- --- --- ---File1
--- --- --- ---File2
--- --- --- ---File3
--- --- ---DirI
--- --- --- ---File1
--- --- --- ---File2
--- --- --- ---File3
soll aufgelöst werden in diese Liste:
/Dir1/Subdir1ofDir1/DirA
/Dir1/Subdir1ofDir1/DirB
/Dir1/Subdir2ofDir1/DirC
/Dir1/Subdir3ofDir1/DirD
/Dir1/Subdir3ofDir1/DirE
/Dir2/Subdir1ofDir2/DirF
/Dir2/Subdir1ofDir2/DirG
/Dir2/Subdir2ofDir2/DirH
/Dir2/Subdir2ofDir2/DirI
der "find"-Befehl gibt mir immer auch alle "Zwischenverzeichnisse" aus, die Liste sieht dann so aus:
find <root> -type d
/
/Dir1
/Dir1/Subdir1ofDir1
/Dir1/Subdir1ofDir1/DirA
/Dir1/Subdir1ofDir1/DirB
/Dir1/Subdir2ofDir1
/Dir1/Subdir2ofDir1/DirC
/Dir1/Subdir3ofDir1
/Dir1/Subdir3ofDir1/DirD
/Dir1/Subdir3ofDir1/DirE
/Dir2
/Dir2/Subdir1ofDir2
/Dir2/Subdir1ofDir2/DirF
/Dir2/Subdir1ofDir2/DirG
/Dir2/Subdir2ofDir2
/Dir2/Subdir2ofDir2/DirH
/Dir2/Subdir2ofDir2/DirI
Kann mir da jemand helfen?
Vielen Dank!
Schönen Gruss,
Stephan