Skip to main content

I want to copy multiple files from one directory to another. I have a variable (files) that contains the following structure: file1 file2.

file1 file2

File1 and file2 are in dir1 and I want to movecopy them to dir2 with the following piece of code that doesn't seem to work:

cp ./dir1/$files ./dir2

I want to copy multiple files from one directory to another. I have a variable (files) that contains the following structure: file1 file2. File1 and file2 are in dir1 and I want to move them to dir2 with the following piece of code that doesn't seem to work:

cp ./dir1/$files ./dir2

I want to copy multiple files from one directory to another. I have a variable (files) that contains the following structure:

file1 file2

File1 and file2 are in dir1 and I want to copy them to dir2 with the following piece of code that doesn't seem to work:

cp ./dir1/$files ./dir2
Source Link
user25
  • 117
  • 1
  • 3
  • 7

How to copy multiple files from one directory to another

I want to copy multiple files from one directory to another. I have a variable (files) that contains the following structure: file1 file2. File1 and file2 are in dir1 and I want to move them to dir2 with the following piece of code that doesn't seem to work:

cp ./dir1/$files ./dir2