简体   繁体   中英

How to grep for all the files in a directory that do not have a set of file extensions?

In a given directory or say a report file that contains a list of names of files with various extensions. Basically I want to list down files that are not of few set of file extensions. say .log, .html, .txt. Can someone please help me to exactly grep excluding these set of file extensions. Thanks in advance

You could try the below grep command.

grep -vE '.*\.(log|html|txt)$' file

From man grep

-v, --invert-match        select non-matching lines

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM