Search code examples
regexbashshellwildcardglob

How can I use wildcard with exception in bash?


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?


Solution

  • you need to change that to

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

    to exclude pcap and gz files