Question

I want to grep multiple files in a folder. I want to grep everyone of them except big files like pcap file and gziped files. So I am trying :

$ grep foo !({*pcap*,*gz*})

But that does not work. Because while it avoid gziped files, the shell expansion of !({*pcap*,*gz*}) returns pcap files actually. Any idea how to include every files except pcap and gziped files please?

Was it helpful?

Solution 2

you need to change that to

grep foo  !(*pcap*|*gz*)

to exclude pcap and gz files

OTHER TIPS

The GLOBIGNORE parameter lists files to exclude from the results of a glob expansion:

Assuming the current directory is empty:

$ touch foo1 foo2 foo3 foo10 foo11 foo12
$ GLOBIGNORE="foo1*:foo3"
$ ls *
foo2

If you don't have extended patterns available you could also use multiple --exclude options:

grep foo * --exclude "*.pcap" --exclude "*.gz"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top