Reputation: 19551
I'd like to do something like
cat *
but which would ignore files that match the pattern __*__
.
What's the best way to do this?
Upvotes: 0
Views: 169
Reputation: 21972
From my today's answer for similar question
ls --ignore="__*__" --quoting-style=shell | xargs cat
Upvotes: 2
Reputation: 56059
If you enable extglob
in bash (shopt -s extglob
), you can use
cat !(excluded_file|excluded_*_pattern)
extglob
patterns:
|
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
Upvotes: 3
Reputation: 45662
$ ls
__a__ __b__ c
$ cat *
aaaaaaaaaaaaa
bbbbbbbbbbbbbb
ccccccccccccccc
$ cat [!_]
ccccccccccccccc
Upvotes: 1