[bash] Bash mkdir and subfolders

Why I can't do something like this? mkdir folder/subfolder/ in order to achive this I have to do:

mkdir folder
cd folder
mkdir subfolder

Is there a better way to do it?

This question is related to bash mkdir git-bash

The answer is


To create multiple sub-folders

mkdir -p parentfolder/{subfolder1,subfolder2,subfolder3}

FWIW,

Poor mans security folder (to protect a public shared folder from little prying eyes ;) )

mkdir -p {0..9}/{0..9}/{0..9}/{0..9}

Now you can put your files in a pin numbered folder. Not exactly waterproof, but it's a barrier for the youngest.


Examples related to bash

Comparing a variable with a string python not working when redirecting from bash script Zipping a file in bash fails How do I prevent Conda from activating the base environment by default? Get first line of a shell command's output Fixing a systemd service 203/EXEC failure (no such file or directory) /bin/sh: apt-get: not found VSCode Change Default Terminal Run bash command on jenkins pipeline How to check if the docker engine and a docker container are running? How to switch Python versions in Terminal?

Examples related to mkdir

How to create nested directories using Mkdir in Golang? Bash mkdir and subfolders How to create a directory and give permission in single command Recursive mkdir() system call on Unix How to create new folder? How to mkdir only if a directory does not already exist? mkdir -p functionality in Python Is there a way to make mv create the directory to be moved to if it doesn't exist?

Examples related to git-bash

"Permission Denied" trying to run Python on Windows 10 Adding Git-Bash to the new Windows Terminal How do I use Bash on Windows from the Visual Studio Code integrated terminal? How can I change the user on Git Bash? Change drive in git bash for windows Running .sh scripts in Git Bash Set an environment variable in git bash Python not working in the command line of git bash Change the location of the ~ directory in a Windows install of Git Bash Username and password in command for git push