Friday, May 3, 2024
17
rated 0 times [  17] [ 0]  / answers: 1 / hits: 14038  / 1 Year ago, thu, march 2, 2023, 2:33:26

I want to create this folder: $HOME/a/b/c/d while $HOME/a has not yet been created! Is it possible with one line in Terminal?


More From » command-line

 Answers
5

You can use the command mkdir with -p option to create a folder inside another non-existent folder. Consider an example,



mkdir -p "$HOME/a/b/c/d"


Where the folders a,b,c and d do not exist in home before running the command. After execution of the command all these folders will be created recursively inside one another.



You can see from man mkdir



-p, --parents
no error if existing, make parent directories as needed

[#26502] Friday, March 3, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jokaned

Total Points: 315
Total Questions: 116
Total Answers: 119

Location: Somalia
Member since Mon, Feb 27, 2023
1 Year ago
;