fabrizio.rocca fabrizio.rocca - 1 month ago 19
Linux Question

Bash, copy files from folder to another

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


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.


I have already tried with that code:

cp /ExercisesOS/2016* /OSLab


but it performs me two error.

How can I write the correct command?

Answer

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/