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. LFD320 Linux Kernel Internals and Debugging
    03 Nov » 07 Nov - Virtual
    Details
  2. LFS416 Linux Security
    03 Nov » 06 Nov - Virtual
    Details
  3. LFS426 Linux Performance Tuning
    10 Nov » 13 Nov - 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