开发者

Regular Expression to select Filenames with exceptions

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜