fix some bugs with manupulating strings with spaces

This commit is contained in:
vulpine 2020-06-26 16:42:22 +00:00
parent 56e3aab304
commit 98ddad1e09
2 changed files with 5 additions and 5 deletions

6
huntnw
View File

@ -1,11 +1,11 @@
#!/bin/bash
QUERY=`echo $1 | tr ' ' ' ' | sed 's/&/\&amp;/g; s/</\&lt;/g; s/>/\&gt;/g; s/"/\&quot;/g; s/'"'"'/\&#39;/g'`
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
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>"
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

View File

@ -12,10 +12,10 @@ Q=$(echo "$QUERY_STRING" | sed -n 's/^.*q=\([^&]*\).*$/\1/p' | sed "s/%20/ /g" |
if [[ $Q ]]
then
./huntnw $Q
./huntnw "$Q"
[[ $(./tser $Q) ]] || echo "<div class='box'>No results :(</div>"
[ -z $(./huntnw "$Q") ] && echo "<div class='box'>No results :(</div>"
fi
cat footer.html