Linux 如何使用位置的相对路径在单个位置创建多个文件夹?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4854277/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I make multiple folders in a single location using relative path to the location?
提问by prasanthv
What I'm trying to do is create a number of folders in the "~/Labs/lab4a/" location (~/Labs/lab4a/already exists).
我想要做的是在“ ~/Labs/lab4a/”位置(~/Labs/lab4a/已经存在)中创建许多文件夹。
Say I want folder1, folder2, folder3all in the lab4afolder.
假设我希望folder1、folder2、folder3都在lab4a文件夹中。
This isn't about making nested folders all at one go using the mkdir -pcommand or going in to lab4aand just making multiple folders at one go. I'm wondering is there a faster way using mkdirto create multiple folders in the same location using relative path.
这不是关于使用mkdir -p命令一次性创建所有嵌套文件夹或进入lab4a并一次性创建多个文件夹。我想知道是否有使用mkdir使用相对路径在同一位置创建多个文件夹的更快方法。
i.eprompt~/: mkdir Labs/lab4a/folder1 folder2 folder3To create all those folders in lab4a at once.
即prompt~/: mkdir Labs/lab4a/folder1 folder2 folder3一次在lab4a中创建所有这些文件夹。
采纳答案by Paused until further notice.
In Bash and other shells that support it, you can do
在 Bash 和其他支持它的 shell 中,你可以做
mkdir ~/Labs/lab4a/folder{1..3}
or
或者
mkdir ~/Labs/lab4a/folder{1,2,3}
Other options:
其他选项:
mkdir $(seq -f "$HOME/Labs/lab4a/folder%03g" 3)
mkdir $(printf "$HOME/Labs/lab4a/folder%03g " {0..3})
Which will give you leading zeros which make sorting easier.
这将为您提供前导零,使排序更容易。
This will do the same thing in Bash 4:
这将在 Bash 4 中做同样的事情:
mkdir ~/Labs/lab4a/folder{001..3}
回答by neuro
Use shell expansion :
使用外壳扩展:
mkdir Labs/lab4a/{folder1,myfolder,foofolder}
That such an underestimated possibility :)
这种被低估的可能性:)
my2c
我的2c
回答by mnichman
Go to console -
转到控制台 -
cd ...
mkdir {8...30}
光盘...
mkdir {8...30}
Create multiple folders linux
linux下创建多个文件夹