Skip to main content

Questions tagged [mkdir]

The tag has no usage guidance.

279 votes
13 answers
149k views

Is there a one-liner that allows me to create a directory and move into it at the same time?

I find myself repeating a lot of: mkdir longtitleproject cd longtitleproject Is there a way of doing it in one line without repeating the directory name? I'm on bash here.
methodofaction's user avatar
47 votes
9 answers
20k views

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's user avatar
  • 1
569 votes
4 answers
693k views

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 ...
user avatar
71 votes
1 answer
102k views

How to create a file and parent directories in one command? [duplicate]

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 ...
Jeff Puckett's user avatar
252 votes
4 answers
196k views

Combined `mkdir` and `cd`? [duplicate]

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 ...
Jasper's user avatar
  • 3,688
4 votes
4 answers
2k views

Make many subdirectories at once

Suppose I have a directory /, and it contains many directories /mydir, /hisdir, /herdir, and each of those need to have a similar structure. For each directory in /, there needs to be a directory doc ...
2mac's user avatar
  • 1,035
4 votes
2 answers
931 views

Command for creating a directory and navigating into it directly? [duplicate]

Quite often I need to perform this two commands: mkdir abc cd abc I am curious whether there is a simple command (or an alias that I can create and use) to do it in one go, like user@GROUP:~$ mdcd ...
shadyyx's user avatar
  • 151
4 votes
3 answers
11k views

What is the fastest way to create a list of directories specified in a file?

I have a text file, "foo.txt", that specifies a directory in each line: data/bar/foo data/bar/foo/chum data/bar/chum/foo ... There could be millions of directories and subdirectories What is the ...
Kaizer Sozay's user avatar
3 votes
1 answer
16k views

Unwanted question mark appended to directory name when using mkdir

I am unsure why when I use mkdir -p $fbase an unwanted ? is appended to the name of the directory (27obs87St01Rec1?) . I have followed similar threads and ran cat -A filename to see if there are ...
B.Andrews's user avatar
2 votes
4 answers
27k views

Creating directory in bulk using mkdir in shell script

I am trying to create directory in bulk using mkdir through shell script below is the script #!bin/bash mkdir /tmp/report*/testfolder*/testdoank when i run it i got an error -bash: ./makefolder.sh: ...
heff's user avatar
  • 21
2 votes
1 answer
274 views

touch/mkdir seems to ignore default ACL

I am pretty sure it is a stupid mistake but I can't seem to figure it out by myself, so please have a look. I set up an ACL for the current folder like so: zigbee2mqtt@nuc:/tmp/folder$ getfacl . # ...
milkpirate's user avatar
1 vote
1 answer
227 views

mkdir -p dir with braces created wrongly

I executed the following code in Ubuntu server 16.04 xenial: mkdir -p /root/backups/{db, dirs} I recall that in another system, it worked like charm creating all 3 dirs: /root/backups/ /root/...
Arcticooling's user avatar
1 vote
2 answers
8k views

Bash can't run command from script: mkdir command not found [closed]

I have separate scripts for tasks in bash. Here is the broken one: #!/bin/bash PATH=/home/name/ mkdir $PATH cd $PATH && echo "done." exit 0 Today it broke and first time it simply didn't ...
NapoleonTheCake's user avatar
0 votes
1 answer
8k views

mkdir error: no such file or directory

on a linux machine running CENTOS v 7.8.2003 I am in a directory Neutrinos I now do mkdir /pionloop/ this works. I then go to into this new directory pionloop and do mkdir /E_0.3 and this works as ...
user3584513's user avatar
0 votes
1 answer
3k views

Creating multiple directories using a parameter in a shell script [duplicate]

I'm trying to make a bash script that would make a series of directories and requesting a parameter of how many directories should be created. $> ./createDir.sh 5 $> ls ex_01 ex_02 ex_03 ...
RayedB's user avatar
  • 3

15 30 50 per page