在linux上创建目录

时间:2017-05-15 11:55:57

标签: bash ubuntu

我被赋予了在ubuntu上创建一个特定的树目录。有人告诉我是否可以在linux上设置已存在目录的父目录?(我的意思是父目录尚不存在)

2 个答案:

答案 0 :(得分:2)

mkdir -p ...
  

-p, - 父母   如果存在则没有错误,根据需要创建父目录

答案 1 :(得分:1)

要使整个树使用-p标志,如:

mkdir -p top/middle/bottom

如果您已经middle/bottom,并且想要将它们推入top/middle/bottom,那么:

#make the top dir
mkdir top
#move middle and bottom into the new directory
mv middle top/
相关问题