Bash,将文件从文件夹复制到另一个

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/40136696/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 15:19:28  来源:igfitidea点击:

Bash, copy files from folder to another

linuxbashfilecopydirectory

提问by fabrizio.rocca

I have a problem with an Uni OS Course assignment. Basically the task says:

我对 Uni OS 课程作业有疑问。基本上任务说:

Deliver now a file for assessment. The content of the file is: one line, containing a command that copies all files with prefix "2016", from directory "ExercisesOS" to directory "OSLab". Consider the current directory to be "~" when writing such command.

立即交付评估文件。文件内容为:一行,包含一条命令,将所有前缀为“2016”的文件从目录“ExercisesOS”复制到目录“OSLab”。编写此类命令时,请考虑当前目录为“~”。

I have already tried with that code:

我已经尝试过使用该代码:

cp /ExercisesOS/2016* /OSLab

but it performs me two error.

但它给我带来了两个错误。

How can I write the correct command?

我怎样才能写出正确的命令?

回答by cpatricio

You probably want to copy from the directory you are working.

您可能想从您正在工作的目录中复制。

To check where you are working:

要检查您的工作地点:

$ pwd
/home/userdir

To copy from your working directory:

要从您的工作目录复制:

$ cp ExerciseOS/2016* OSLab/

回答by riki ruslan

mkdir OSLab && cp /ExercisesOS/2016* OSLab

This solution would assume that the directory 'OSLab' isn't already created.

此解决方案假定尚未创建目录“OSLab”。