P
Pero
I want to write search script in perl.
How to make list of all htm file on Linux - Apache web server?
Tnx.
How to make list of all htm file on Linux - Apache web server?
Tnx.
I want to write search script in perl.
How to make list of all htm file on Linux - Apache web server?
Pero said:I want to write search script in perl.
How to make list of all htm file on Linux - Apache web server?
Pero said:I want to write search script in perl.
How to make list of all htm file on Linux - Apache web server?
David said:Perl is a big hammer for such a small nail.
How about just typing this at your commandline:
find . -name "*.htm"
(that recurses down from your current directory. cd to \ if you want
to find ALL such files anywhere they may exist. But you probably
want to start at your Apache DocumentRoot).
"find" doesn't do this on Windows. On Unix there is no "\" to cd too. SoDavid said:Perl is a big hammer for such a small nail.
How about just typing this at your commandline:
find . -name "*.htm"
(that recurses down from your current directory. cd to \ if you want
to find ALL such files anywhere they may exist. But you probably want
to start at your Apache DocumentRoot).
$ find . | grep -P 'html?$'
Dr.Ruud said:szr schreef:
That is quite wasteful, even if the current directory doesn't contain
millions of subdirectories and files.
And it would erroneously return ./test_html and such.
$ find . -type f -name "*.htm" -or -name "*.html"
$ find . -type f -regex ".*\.html?"
Dr.Ruud said:szr schreef:
That is quite wasteful, even if the current directory doesn't contain
millions of subdirectories and files.
Glenn said:They're not regular expressions: they're shell glob patterns.
Aside form forgetting *. which should of been at the beginning of my
patterns, is it really more wasteful?
Does find not have to also check
each file it comes across too?
Or is it just the over of piping the
final output from find over to grep?
Other then that I don't see why it
would be more wasteful?
On my both my Dual core Linux system as well as
an old P2 400 also running Linux, I see no difference in speed, even on
a large sprawling directory.
find does it's thing, grep prunes it's results.
Doug said:Yes, absolutely.
Certainly. But you're piping *all* of them to grep, thus making both
find *and* grep process all of them.
Yep.
s/over/overhead/
That, too.
Because it:
a) creates, opens, and closes a pipe that is not necessary
b) spawns an additional process (grep) that is not necessary
c) ships *every* filename across that unnecessary pipe to that
unnecessary process to be filtered
.. when you could instead simply filter the filenames at the source,
as
they're generated by find.
That's because
a) you're on a single-user machine, and
b) you're not examining a large enough directory to notice the
difference.
Try that in a multi-user environment with typical production
directory trees, and the difference will become visible.
Pointless. find can both find *and* prune.
find does it's thing, grep prunes it's results.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.