开发者

Regular Expression to select Filenames with exceptions

开发者 https://www.devze.com 2023-01-18 20:53 出处:网络
How do I select all files in a directory with exception of few files like file-1.php, file-2.php and file-3.php ?

How do I select all files in a directory with exception of few files like file-1.php, file-2.php and file-3.php ?

The exception file names can be anything like file-a.php, arbit-file-name.php or anything.jp开发者_C百科g. Its not a sequential set of files like file-1 etc.


How about

ls | grep -v '^(file\.php|random\.jpg|whatever\.txt)$'

EDIT: modified to allow arbitrary files.


Ok I found it...

^(((?!file-a\.php)(?!random\.jpg)(?!whatever\.txt)).)*$
0

精彩评论

暂无评论...
验证码 换一张
取 消