Linux.com

Home Learn Linux Linux Answers Internet can you copy two files at the same time to a directory using just one command to do this
Answers
  • type "man copy" into a terminal, and you can see how it works.

    cp filename1 filename2 /somedirectory

    Answered by Goineasy9
    4 years ago
    0 2
  • if you literally mean "at the same time" you can use parallel - its a very usefull tool which provides you with ability to paralelize execution of several task or to execute a complex task in parallely. In you situation it would look something like this:

    ls * | parallel --jobs +4 'cp {} /some_dir'

    which means that parallel will take create 4 threads and every of them will try to copy one file piped from "ls" command

    Answered by dagon
    4 years ago
    0 0
  • Or, if you have more than one to copy at a time, you can try tools like rsync and cpio.

    Also, if the files in question have similar attributes, you can use something like 'find' with the -exec argument like:

    find /path/to/old/dir -name "file1" -o -name "file2" -exec cp {} /path/to/new/dir \;

    Answered by gomer
    4 years ago
    0 0
  • There are multiplse ways to accomplish this by the simplest is by using the sample script that goineasy9 has given.

    If you wish to use more dynamic or network based functions your should look into xargs, find, rsync and scp.

    Answered by mfillpot
    4 years ago
    0 0
Please register/login to answer this question. Click here to login
Similar Questions Found
Questions from category Internet

Upcoming Linux Foundation Courses

  1. LFS230 Linux Network Management
    06 Oct » 09 Oct - Virtual
    Details
  2. LFD331 Developing Linux Device Drivers
    13 Oct » 17 Oct - Virtual
    Details
  3. LFS430 Linux Enterprise Automation
    13 Oct » 16 Oct - Virtual
    Details

View All Upcoming Courses

Community Answers - Search


Who we are ?

The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.

More About the foundation...

Frequent Questions

Join / Linux Training / Board