Created
September 28, 2012 19:21
-
-
Save seblavoie/3801653 to your computer and use it in GitHub Desktop.
Plain text directory structure creation in bash
This file contains hidden or 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
# Creates folder structure from plain text. | |
# Based on this stackoverflow question and answer http://stackoverflow.com/questions/12642260/better-bash-script-to-create-directory-structure | |
mkdirs($file) { | |
sed -f mkdirs.sed $file | xargs mkdir -p | |
} |
This file contains hidden or 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
#!/bin/sed -f | |
s/^// | |
x | |
G | |
: loop | |
s:\([^/]*\)/*\(.*\n\)\([^|]*\)|\s:\2\3\1/: | |
t loop | |
s/.*\n// | |
s:/*$:: | |
h |
This file contains hidden or 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
folder-01 | |
| subfolder-01 | |
| subfolder-02 | |
| | deeper-subfolder-01 | |
| | deeper-subfolder-02 | |
folder-02 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment