Create striped folders in Bash
If you ever need a hierarchy of folders like the following just use bash's built in expansion to do this in one command.
This command will create 3 levels of directories, each having folders 0 to 9.
mkdir -p {0..9}/{0..9}/{0..9}
Using mkdir's -p
flag allows the child (and grandchild) directories to be created without the parent necessarily being created. The {0..9}
is one of bash's normal expansion characters and it expands to the range 0 to 9.
Written by Jon Dowdle
Related protips
2 Responses
Clever... I'm a fan of parameter expansion with bash shell Never thought of using it this way before.
over 1 year ago
·
yes, this is really good.
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Folder
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#