htgrep

    Status : stable
Download : htgrep (5 KB)

This is a frontend to the well known grep tool, using HTML as output. You can first see the matches with a quick glance in the summary part, then jump to a specific context with a single clic, and finally reach the source file if it happens to be online somewhere.

Self documentation

sh: 1: htgrep: not found

PHP frontend example

You can try it here.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
 <title>Matches for <?php echo $q ?></title>
 <style type="text/css">
FONT.match { color: #A00000; font-weight: bold }
DIV.code { width: 100%; border: none; background-color: #eeeeee }
TR.title { background-color: #c8c8c8; font-weight: bold; }
TR.match { background-color: #e8e8e8; }
  </style>
</head>
<body>

<?php
$q 
$_REQUEST['q'];
$n $_REQUEST['n'];
?>

<h1>htgrep</h1>

<form method=get action="htgrep.php">
<table border=0>
 <tr>
  <td align="right">Search :</td>
  <td><input type=text name="q" size=16 value="<?php echo $q ?>"> <input type=submit value=" OK "></td>
 </tr>
 <tr>
  <td align="right">Context size :</td>
  <td><input type=text name="n" size=4 value="<?php echo $n ?>"></td>
 </tr>
</table>
</form>

<?php
if ($q != "") {
  
$path '/var/www/zerodeux.net/http/projects/htgrep';
  
$prog '/usr/local/bin/htgrep';
  
$urlbase 'http://cvs.gna.org/viewcvs/ngl/';
  
$q escapeshellarg($q);
  if (!isset(
$n) || !is_int($n)) $n 3;
  
system("cd '$path' && '$prog' -n '$n' -u '$urlbase$q ngl/include ngl/src");
}
?>

</body>
</html>