我想做点什么
cat *
但会忽略与模式__*__
匹配的文件。
最好的方法是什么?
答案 0 :(得分:3)
如果您在bash(extglob
)中启用shopt -s extglob
,则可以使用
cat !(excluded_file|excluded_*_pattern)
extglob
模式:
|
or/alternatives
?(pattern-list)
Matches zero or one occurrence of the given patterns
*(pattern-list)
Matches zero or more occurrences of the given patterns
+(pattern-list)
Matches one or more occurrences of the given patterns
@(pattern-list)
Matches one of the given patterns
!(pattern-list)
Matches anything except one of the given patterns
答案 1 :(得分:2)
来自my today's answer for similar question
ls --ignore="__*__" --quoting-style=shell | xargs cat
答案 2 :(得分:1)
也许不是最佳方式,但是:
tcsh -c 'echo ^__*__'
答案 3 :(得分:1)
$ ls
__a__ __b__ c
$ cat *
aaaaaaaaaaaaa
bbbbbbbbbbbbbb
ccccccccccccccc
$ cat [!_]
ccccccccccccccc