huntnw/huntnw

12 lines
465 B
Bash
Executable File

#!/bin/bash
QUERY=`echo $1| sed 's/&/\&amp;/g; s/</\&lt;/g; s/>/\&gt;/g; s/"/\&quot;/g; s/'"'"'/\&#39;/g'`
for fn in $(grep -rEic "$QUERY" content | grep -v ':0' | sort -t: -nrk2 | awk -F: '{print $1}');do
PA=$fn
echo "<div class='box'><a href='"`head -n 2 $PA | tail -n 1`"'>"`head -n 1 $PA | head -c 30`"</a><p>"`grep -i "$QUERY" $PA | sed 's/&/\&amp;/g; s/</\&lt;/g; s/>/\&gt;/g; s/"/\&quot;/g; s/'"'"'/\&#39;/g' | head -n 2 | head -c 100`"</p></div>"
done