Regular expression – How to use an abnormal wildcard in Bash?

See answer in English> Automatically ignore files in grep 6
I want to grep multiple files in the folder. In addition to large files like pcap files and gziped files, I want to render them a lot. So I want to:

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

But this does not work. Because although it avoids gziped files, but! The shell extension of ({* pcap *,* gz *}) will actually return pcap files. Do you know how to include all files except pcap and gziped files?

you need to change it

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

Exclude pcap and gz files

See answer in English> Automatically ignore files in grep 6
I want to grep multiple files in a folder. In addition to large files like pcap files and gziped files, I want to render them lavishly. So I thought:

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

But this does not work. Because although it avoids gziped files, it! The shell extension of ({* pcap *,* gz *}) will actually return pcap files. Do you know how to include all files except pcap and gziped files?

You need to change it

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

Exclude pcap and gz files

Leave a Comment

Your email address will not be published.