- Create 50 files whose names are from
1
to50
.- Create five folders (
0
,10
,20
,30
,40
).- Copy those 50 files into folders based on their name (for example, file
21
will go to folder20
).
我已经创建了这些文件和文件夹,但不知道如何将特定文件移动到特定文件夹。我试着写
cp {1..9} /home/user/folder
但这是 Not Acceptable 。是否可以使用 if
和 elif
?
最佳答案
cp {1..9} /home/user/folder
这会起作用,除非您应该指定要复制到的正确文件夹。也许您指的是其中之一?
cp {1..9} /home/user/folder/0
cp {1..9} 0
另一种方法是使用通配符。 *
匹配任何字符串,?
匹配任何一个字符。例如,2?
将匹配文件名 20
到 29
。
关于linux - 如何将特定文件复制到特定文件夹 linux bash,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41106259/