Explore Courses Blog Tutorials Interview Questions
0 votes
in Linux by (18.4k points)
edited by

I am trying to copy several files from 1 folder to another. How do I do it using the shell command prompt?

Consider that folder1 contains ten files (e.g. file1, file2, abc, xyz, etc.). I am currently working on the following in order to copy the 2 files from one folder to other:

cp /home/ankur/folder/file1 /home/ankur/folder/file2 /home/ankur/dest

I Typed the full path into the above command line for 2 files is annoying.

What comes to my mind is the regex, but I don't know much about it.

1 Answer

0 votes
by (36.8k points)

I think you are looking for the brace expansion use the below command:

cp /home/ankur/folder/{file1,file2} /home/ankur/dest

Take a look here 

To know about Linux join the Linux training

Related questions

Browse Categories