如何复制目录中的每个文件,但具有 2 个不同扩展名的文件除外?
How to copy every file in a directory except those with 2 different extensions?
我想将当前目录下的所有文件复制到目录"folder_1",除了那些以.txt和.png结尾的文件
我尝试了以下方法:
shopt -s extglob
cp !(*.txt) folder_1
但我需要使它更通用以包括 png 以及
cp !(*.txt|*.png) folder_1
If the extglob shell option is enabled using the shopt builtin, several extended pattern matching operators are recognized. In the following description, a pattern-list is a list of one or more patterns separated by a ‘|’. Composite patterns may be formed using one or more of the following sub-patterns:
...
!(pattern-list)
Matches anything except one of the given patterns.
我想将当前目录下的所有文件复制到目录"folder_1",除了那些以.txt和.png结尾的文件
我尝试了以下方法:
shopt -s extglob
cp !(*.txt) folder_1
但我需要使它更通用以包括 png 以及
cp !(*.txt|*.png) folder_1
If the extglob shell option is enabled using the shopt builtin, several extended pattern matching operators are recognized. In the following description, a pattern-list is a list of one or more patterns separated by a ‘|’. Composite patterns may be formed using one or more of the following sub-patterns:
...
!(pattern-list)
Matches anything except one of the given patterns.