tags:

views:

31

answers:

2

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.jpg. Its not a sequential set of files like file-1 etc.

A: 

How about

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

EDIT: modified to allow arbitrary files.

bitmask
The sequence that I gave in the question earlier was just a mere coincidence. I have updated the question accordingly.
GeekTantra
like that? (edited)
bitmask
doesn't seem to work as expected...
GeekTantra
A: 

Ok I found it...

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