How to copy multiple files from a different directory using cp?

前端 未结 3 472
情话喂你
情话喂你 2020-12-13 05:40

I want to copy multiple files from a specific directory once I am in another directory. To clarify I want to do the following, at once (one command):

cp ../         


        
3条回答
  •  眼角桃花
    2020-12-13 06:29

    If all the files you want to copy are in the pattern of file{number}{othertext}, you could use something like:

    cp ../dir5/dir4/dir3/dir2/file[0-9]* .
    

    Note that this will copy file5, but it will also copy file0abc.

    If you would like to copy ONLY those four files (and not the {othertext} ones), you can use:

    cp ../dir5/dir4/dir3/dir2/file[1-4] .
    

    Note that while this looks like part of a regular expression, it is not.

提交回复
热议问题