2011-12-16 220 views

回答

3

如果啓用在bash(shopt -s extglobextglob,您可以使用

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 
+0

我在達爾文,你的`extglob`使代碼運行提供了`-bash:禁用了javascript:extglob:無效選項name` – 2011-12-16 19:32:08

+0

對不起,我`-o`最初(混吧使用`set -o`),你用修正的`-s`來試試它嗎? – Kevin 2011-12-16 19:38:32

1

也許不是最好方式,但:

tcsh -c 'echo ^__*__' 
1
$ ls 
__a__ __b__ c 

$ cat * 
aaaaaaaaaaaaa 
bbbbbbbbbbbbbb 
ccccccccccccccc 

$ cat [!_] 
ccccccccccccccc 
相關問題