mkdir with intermediate directories and rails generate view specPosted: June 19, 2014 | Author: ThomasPowell | Filed under: daily learning | Tags: rspec, shell | Leave a comment »
I’ve been running into a lot of cases where I need to build intermediate directories for a path. Apparently, the correct option is
mkdir -p dir/tree/to/make
mkdir man page:
-p Create intermediate directories as required. If this option is not specified, the full path prefix of each operand must already exist. On the other hand, with this option specified, no error will be reported if a directory given as an operand already exists. Intermediate directories are created with permission bits of rwxrwxrwx (0777) as modified by the current umask, plus write and search permission for the owner.
I’ve assigned it an alias in my
alias mkdirtree='mkdir -p'
Of course, this all came about because I needed to an generate rspec file for a view, which can be done with:
rails g rspec:view name/of/controller action another_action
Results in the following files in the