相关疑难解决方法(0)

在unix/linux shell中进行模式匹配时,如何使用反向或负向通配符?

假设我想复制目录的内容,不包括名称中包含"音乐"一词的文件和文件夹.

cp [exclude-matches] *Music* /target_directory
Run Code Online (Sandbox Code Playgroud)

什么应该代替[exclude-matches]来实现这个目标?

bash shell glob pattern-matching

317
推荐指数
8
解决办法
17万
查看次数

列出与模式不匹配的文件?

以下是如何列出与bash中的模式匹配的所有文件:

ls *.jar
Run Code Online (Sandbox Code Playgroud)

如何列出模式的补充?即所有文件都不匹配*.jar?

bash ls glob wildcard

55
推荐指数
7
解决办法
5万
查看次数

Pattern match does not work in bash script

Using the pattern match !("file1") does not work within a bash script but will work on the command line.

For example:

ls  !("file1"|"file2")
Run Code Online (Sandbox Code Playgroud)

This will list all files in directory except file1 and file2.

When that line is executed in a script this error is displayed:

./script.sh: line 1: syntax error near unexpected token `('
./script.sh: line 1: ` ls  !("file1"|"file2") ' 
Run Code Online (Sandbox Code Playgroud)

Regardless what is used rm -v !("file1"). The same error takes place. What is going on …

linux bash glob extglob

13
推荐指数
2
解决办法
469
查看次数

标签 统计

bash ×3

glob ×3

extglob ×1

linux ×1

ls ×1

pattern-matching ×1

shell ×1

wildcard ×1