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)).)*$
精彩评论