#! /usr/local/bin/bash # Linux Academy / Linux cause text notes searh # Copyright 2019 ycos Systems, A.Yakoshi ## Environment values BASE=../ # Search directory top WORK=/tmp/ycos2.search # work file ## Test stub funciton function test() { cat < `env |sort ` `echo QUERY_STRING $QUERY_STRING | nkf -w --url-input` EOD exit 0 } ## Search Keyword decode KEY="`echo $QUERY_STRING | nkf -w --url-input |cut -d= -f2-`" ## HTTP Header cat < Search result $KEY

検索結果

キーワード "$KEY" を含む URL 一覧

EOD # test # for test stub ## main logic for d in ${BASE}/* # Narrow down seach directoris do # Pick up HTML files find $d -name "*.html" -o -name "*.txt" -type f 2>/dev/null done | cut -d: -f1 |sort -u > $WORK # select uniqe file name # Keyword URL decode search it # Exclude HTML keyword # sElect uniqe file name grep -wi "$KEY" `cat $WORK` |grep -v "$KEY>"| cut -d: -f1 |sort -u | # create HTML (A Tag) awk '{ t=substr($1, 4, length($1));printf "%s
\n", $1, t}' # trailer cat < [ TOP ] EOD # remove a work file rm -f $WORK