Questions tagged [mkdir]
154 questions
541
votes
4 answers
recursive mkdir
Is there a linux command that I'm overlooking that makes it possible to do something along the lines of:
(pseudo)
$ mkdir -R foo/bar/zoo/andsoforth
Or is there no alternative but to make the directories one at a time?
Dr.Dredel
241
votes
4 answers
Combined `mkdir` and `cd`?
is there any way (what is the easiest way in bash) to combine the following:
mkdir foo
cd foo
The manpage for mkdir does not describe anything like that, maybe there is a fancy version of mkdir? I know that cd has to be shell builtin, so the same…
Jasper
- 3,538
- 4
- 16
- 22
185
votes
2 answers
How to create nested directory in a single command?
Apparently, it's not possible to create a nested directory in a single command?
$ sudo mkdir x/y/z
mkdir: cannot create directory 'x/y/z': No such file or directory
BaltoStar
- 2,331
- 3
- 16
- 11
69
votes
1 answer
How to create a file and parent directories in one command?
Is there a flag/option for touch, mkdir, >, or some other command that will allow me to create a file and any non-existent parent directories at the same time?
For instance, let's say I'm in an empty folder. Now I can create parent directories if…
Jeff Puckett
- 859
- 1
- 8
- 12
46
votes
9 answers
mkdir -p for files
mkdir -p will create a directory; it will also make parent directories as needed.
Does a similar command exist for files, that will create a file and parent directories as needed?
Zombo
- 1
- 5
- 43
- 62
39
votes
4 answers
Is mkdir -p totally safe when creating folder already exists
Say I have a folder:
./folder/
Inside it there are many files and even sub-directories.
When I execute:
mkdir -p folder
I won't see any errors even warnings.
So just want to confirm, is there anything lost or changed in result of this command?
AGamePlayer
- 7,415
- 16
- 46
- 55
26
votes
3 answers
Creating multiple nested directories with one command
How can I create multiple nested directories in one command?
mkdir -p /just/one/dir
But I need to create multiple different nested directories...
user3142695
- 1,529
- 7
- 20
- 34
15
votes
3 answers
Why did my folder names end up like this, and how can I fix this using a script?
Sorry if this has an answer elsewhere, I've no idea how to search for my problem.
I was running some simulations on a redhat linux HPC server, and my code for handling the folder structure to save the output had an unfortunate bug. My matlab code to…
Bamboo
- 485
- 4
- 8
13
votes
1 answer
How many directories can be nested?
I'm curious, how many folders can be nested, and why? Is there a limit?
What I mean by nested is when folders are in this structure:
folder
|_ folder
|_ folder
|_ folder
|_ ...
Not like this:
folder
|_ folder
|_…
Aaron Esau
- 365
- 1
- 4
- 13
12
votes
4 answers
Recursively create directories for all letters
I want to create a directory in such a way that I need to label the directories from a to z. Inside each of these directories, I need to create sub-directories so that they are labelled as aa, ab etc.
So, for instance, for the directory m, my…
Ramesh
- 38,687
- 43
- 140
- 215
10
votes
5 answers
Create the same subfolders in another folder
I have a directory foo with subdirectories. I wish to create the same subdirectories names in another directory without copying their content. How do I do this?
Is there a way to get ls output as a brace expansion list?
havakok
- 237
- 3
- 8
9
votes
2 answers
Deleted /tmp accidently
Accidently, I ran sudo rm -r /tmp, is that a problem ?
I recreated it using sudo mkdir /tmp, does that fix the problem ?
After I recreated the directory, In the places section in the sidebar in nautilus in Ubuntu 14.04 I can see /tmp , which wasn't…
Amr Ayman
- 435
- 1
- 6
- 15
8
votes
1 answer
How does 'Create New Folder' short-key work?
In many file managers there is a shortcut/key to create a new folder. In Nautilus, Thunar, Panthon-Files, this is Ctrl+Shift+N, in Dolphin it is F10.
How does this shortcut work?
I imagine that behind it it's a mkdir command, but that would need a…
user32012
7
votes
1 answer
Will `mv` ever have the ability to create directories?
This question asks for the best way to create a directory when using mv if it doesn't exist. My question is why isn't this an inbuilt feature of mv? Is there some fundamental reason due to which this would not be a good idea?
texasflood
- 501
- 2
- 5
- 13
6
votes
2 answers
Make parent directories while creating a new file
I am aware of the fact that mkdir -p /path/to/new/directory will create a new directory, along with parent directory (if needed ).
If I have to create a new file, along with it's parent directories (where some or all of the parent directories are…
Mandar Shinde
- 3,156
- 11
- 39
- 58