Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
260 views
in Technique[技术] by (71.8m points)

linux - Is it possible to recursively create folders using a shell script?

I'm trying to recursively create levels of directories like /folder1/folder2/folder3

I'm trying mkdir folder1/folder2/folder3, but it doesn't work. How can I do it?

question from:https://stackoverflow.com/questions/8274920/is-it-possible-to-recursively-create-folders-using-a-shell-script

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You should pass the -p parameter to mkdir so it will create all the subfolders. So following your example:

mkdir -p folder1/folder2/folder3

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...