Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In my lab, we are trying to build a web that allows the user to enter queries for find, ack, grep on a specific directory. The web would return an HTML with a table of a list of clickable files (click on them would download the file).

For example, in this interface the user would type a word in a form in the browser, and the system would call find . -name "*word*" and send back an HTML with the result.

Has anything like this been done before? We would like to avoid reinventing the wheel. What toolkits, utilities or packages would be helpful to build this functionality?

share|improve this question
Hundreds of times. I guess everybody who ever used CGIs did that or a similar thing at one point or another. Also, it is pretty straightforward to get using a simple Perl script, if what you are looking for is simplicity, then maybe this will be easier than to install and configure something way more complex. – January Oct 15 '12 at 18:08
@January, I'm not so sure about the simplicity of the task. By default from a CGI script find and grep will probably run with other user's permissions than the one using the web interface, so they will not be able to access a lot of files. And while a brute force search with find and grep may take quite long, some intermediary feedback to the user will be needed. Additionally you may have to overcome the web server's maximum request time limitation. And if the result list is too long, some paging, preferably with caching, will be needed too. – manatwork Oct 16 '12 at 7:47
@manatwork: first, the permissions are not an issue, since we are talking "specific directory" and read only access. Also, to do it properly, yes, it would require more effort. But to do it properly, no one will build a web interface to command line tools for searching files in lieu of a database. – January Oct 16 '12 at 7:49
@January, you are right. But as I understand, user27915816 wants a solution usable in their daily work. Maybe a desktop search engine would serve his needs better. For example Beagle desktop search engine with Peagle web interface. – manatwork Oct 16 '12 at 8:03

My favorite solution in this case is a CGI perl script. In this way you can handle special cases like

word = " -delete -name "

and you have to provide a mapping from a path in your file system to a web server url.

share|improve this answer
+1 for touching on input sanitization. I don't think this has been emphasized enough here. – Joseph R. Aug 3 '13 at 19:06

At its simplest, what you are asking for is very easy:


 <form action="../cgi-bin/find_files.pl" method="POST">
  <input type="text" name=name></input>
  <input type=submit>

Perl script

use CGI qw(:standard);
use CGI::Carp qw(warningsToBrowser fatalsToBrowser); 
my $cgi = new CGI;
my $target='/tmp';   ## directory to search in
my $name = $cgi->param('name') || carp("no search terms entered");
my $res=`find $target -name $name`;
my @lines=split(/\n/,$res);
print header;
print "<table>";
foreach my $line (@lines) {
    print "<tr><td>$line</td></tr>";
print "</table>";
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.