Suppost I want to create a directory like "a/b/c" under the current dir.
How to make it?
I have tried this:
Dir.mkdir("a/b/c").
However it does not work.
I guess this is because parent directories of c do not exist. If you try to do the same in the shell you will also get an error. You can force creation of parent directories if they do not exist with the -p option:
mkdir -p a/b/c
which in Ruby can be done with mkdir_p found in the FileUtils module:
require "fileutils"
FileUtils::mkdir_p "a/b/c"
What can make your life much easier is
system 'mkdir "/home/awais/development/rails/testing2"'
path needs to be within double quotes "..", I'm struggling to get this to work now where I want a variable that carries this nested path. Any ideas using the system command? system('mkdir #{path/to/dir}') didn't work, neither does system('mkdir "#{path/to/dir}" ') which creates a directory with the literal text between the quotes