zuloocyprus.blogg.se

Perl grep directory
Perl grep directory






perl grep directory

Imitation is clearly the highest form of flattery.

PERL GREP DIRECTORY CODE

Like ack and ag it also ignores code repo files you don’t want to search through. This solution is coded in Go and makes fantastic use of Go’s built in concurrency support to obtain its solid performance. I discovered this when Dave Cheney gave a shoutout to Monochromegane’s The Platinum Searcher on episode 16 of the stellar Go Time podcast. We are working towards our upcoming ActiveGo™ distribution and I would be remiss if I didn’t mention another fantastic grep-like tool built out of Go that is performance equivalent to ag. Lastly, we’ve been doing a lot of work with the Go language here at ActiveState. hgignore files and you can even specify your own. It also ignores files you normally don’t want to be searching in your codebase and looks for. Now, instead of “ack”, we can just type the clever “ag”, which is the periodic table chemical symbol for silver: This fantastic tool claims to be an order of magnitude faster than ack due to its implementation in C and use of pthreads to provide concurrency among many other improvements. This brings us to Geoff Greer’s feature-rich, ack-inspired, The Silver Searcher (great name!). However, ack has a performance weakness…it still isn’t concurrent out-of-the-box (but could be used in a similar way like in the above grep example). Typical usage:Īck, why didn’t you specify the directory to search from? Well in order to be maximally productive, it defaults to recursive directory search from the current working directory! This is perfect when searching your code trees. It also has the advantage of using Perl’s regular expressions which have always been top notch amongst languages.

perl grep directory

In the Perl world we have Andy Lester’s excellent ack! This works on any Perl (or ActivePerl of course!) A great benefit for developers, it ignores your coredump files, binaries, backup and code repository files. In fact, why don’t we have a tool that is both fast, concurrently capable, and tailored to the needs of developers? In fact, we do! This gets the job done, but surely we can more productive than this for our everyday development. I say “potential” as there are many factors involved including your search tree, hardware, IO bottlenecks, etc. Now you can break up a grep in a variety of ways in order to inject some potential concurrency upside for your search. Grep uses a single thread to do its work, and performance clearly suffers over large filesets even with our modern powerful systems. A good example is the source code for the linux kernel which at version 1.0 in 1994 consisted of 170,000 lines of code, and as of version 4.8 is now over 22M lines of code.Īs you can well imagine, grep on most systems is fairly dated when taking modern multicore processors into account. However, as time and technology has advanced, the sheer size and number of files has grown at a rapid rate. Grep has been the defacto standard for programmers everywhere to find stuff in files.

perl grep directory

Originally invented by computer science luminary Ken Thompson in November 1974, it was originally developed for the Unix operating system, but is available today, in some form or another, on almost all systems. Grep is the ubiquitous command line tool for finding lines in files that match a pattern.








Perl grep directory