[Linux] CP bulk copy file

[Requirements]:

   There are 2 folders a, b, now you need to copy all the files (aa.py, a2.py, a3.py) in folder a to folder b (empty folder)

[Solution Method]:

   The first thing that comes to mind is to use regular expressions, but I found that In linux, only grep, awk, sed and other commands can support regular expressions.

And commands like ls, find, cp are not supported Regular expressions, but you can use the shell’s own wildcards to match

[Example]:

  a folder:

Share a picture

  b folder:

span>

share picture

[Use command]:

cp dir1/* dir2

cp example:

share picture

[Effect]:

  3 files in folder a have been copied to folder b

Share a picture

Reference documents:

linux——cp, Examples of wildcards and mv commands

cp dir1 /* dir2

Leave a Comment

Your email address will not be published.