[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: regular expression?



William Jensen wrote:
> 
> Greetings,
> 
> I am trying to find a regular expression that will include every file
> in a directory except one named one.  For example if I had a file
> called index.html and then hundreds of other .html files in the same
> directory, how can I do a reg expression to say "all the .html files"
> except index.html?  Been rack'n my brain on this one for a bit of time
> and I could use some help from someone more experienced.

  don't think you can do it with REs, here's grep command you can use on
command line:

  ls | grep -v '^index.html$'

  if you're doing it in some script/program you will have to implement
it that way yourself - example in perl:

#!/usr/bin/perl
#

use strict;

my($pattern) = 'index.html';
my(@list)    = glob('*');

print "file list:\n";
foreach(@list) { print "\t$_\n"; }

@list = grep { ! /$pattern/ } @list;

print "file list with no [$pattern]\n";
foreach(@list) { print "\t$_\n"; }

__END__

  in other words you do not specify the negation in RE but instead in
context where RE is used.

	erik



Reply to: