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
  • type "man copy" into a terminal, and you can see how it works.

    cp filename1 filename2 /somedirectory

    Answered by Goineasy9
    5 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
    5 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
    5 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
    5 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. LFS101 Introduction to Linux
    01 Jan » 31 Dec - Online Self-Paced
  2. LFS201 Essentials of System Administration
    01 Jan » 31 Dec - Online Self-Paced
  3. LFS201-Esp Fundamentos de Administración de Sistemas Linux
    01 Jan » 31 Aug - Online Self-Paced

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