Created
November 17, 2014 22:15
-
-
Save rhettc/ba33e5b58b2dcf0c0c04 to your computer and use it in GitHub Desktop.
use find to duplicate the parent directory’s structure into the current directory, files are not copied
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# given the structure | |
../foo/bar | |
../fizz/bang | |
../beep | |
# move into the beep child dir and run the command | |
cd beep | |
find ../ -mindepth 1 -type d -printf "%P\0" | xargs --null mkdir | |
# now beep has the same structure | |
./foo/bar | |
./fizz/bang | |
./beep | |
# mindepth 1 prevents the "." from being printed as a match | |
# printf is used to print the leading part of the path except for the "../" | |
# --null tells xargs about the null terminator we included in our print format |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment