ls is a command.  I believe it comes with the GNU fileutils package.

Anyway, the perl script seems to work pretty good for basic regular
expressions...   I suppose if anyone needed a really complicated regular
expression for ls they could just write their own perl script- might be
easier.   :-)

-----Original Message-----
From: tclug-list-admin at mn-linux.org
[mailto:tclug-list-admin at mn-linux.org]On Behalf Of Troy.A Johnson
Sent: Thursday, July 12, 2001 10:17 AM
To: tclug-list at mn-linux.org
Subject: Re: [TCLUG] ls with regular expression


Isn't 'ls' usually a shell built-in command? If so, you would
probably find the closest "equivalent" in the docs for the
shell (bash, tcsh, ksh,...).

You could probably write your own such utility on perl (or
python I imagine):

pls:
=======================
#!/usr/bin/perl -w
my $regex = join(" ", @ARGV);
opendir(DIR, ".");
@files = readdir(DIR);
closedir(DIR);
foreach $file (@files)
{
   if ($file =~ m/$regex/)
   {
      print "$file\n";
   }
}
======================

It could be done shorter, but it is clearer I think.
But there is the "escaping everything the shell
wants to grab" problem... :-/

Troy

>>> list at slushpupie.com 07/12/01 09:52AM >>>
Does anyone know of a ls equivalent that supports regular expression
matching?

ie- do things like this:

ls /^[A-Z]/

I know this can be done by piping to other commands (grep, awk, sort, etc)
but is there a command that just does it?

Jay



--
Jay
Publishing Business Systems
651-634-9217

_______________________________________________
tclug-list mailing list
tclug-list at mn-linux.org
https://mailman.mn-linux.org/mailman/listinfo/tclug-list

_______________________________________________
tclug-list mailing list
tclug-list at mn-linux.org
https://mailman.mn-linux.org/mailman/listinfo/tclug-list