search.sh - gopher-lawn - The gopher lawn gopher directory project. | |
git clone git://bitreich.org/gopher-lawn/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhf… | |
Log | |
Files | |
Refs | |
Tags | |
--- | |
search.sh (745B) | |
--- | |
1 #!/bin/sh | |
2 # | |
3 # TODO: Add real search based on new db layout. | |
4 # | |
5 | |
6 if [ $# -lt 1 ]; | |
7 then | |
8 printf "usage: %s search\n" "$(basename "$0")" >&2 | |
9 exit 1 | |
10 fi | |
11 | |
12 X_GOPHER_SEARCH="$1" | |
13 | |
14 cat c/*.gph \ | |
15 | tr '\n' '\t' \ | |
16 | sed 's,\t\t,\n,g' \ | |
17 | grep '^\[' \ | |
18 | grep -v '^\[1|<< back|/lawn|server|port\]$' \ | |
19 | grep -i "${X_GOPHER_SEARCH}" \ | |
20 | sort \ | |
21 | uniq \ | |
22 | sed 's~^\[~\n&~' \ | |
23 | tr '\t' '\n' | |
24 | |
25 # Old: Thanks KatolaZ! | |
26 # Adapted from: gopher://kalos.mine.nu/0/software/search_lawn.dcgi | |
27 #IDX="index.gph" | |
28 #STRIP="/lawn/" | |
29 # | |
30 #IFS=' | |
31 #' | |
32 #grep "^\[.*|/lawn.*|server|port]" ${IDX} | cut -d "|" -f 3 | while read… | |
33 # subdir="${sel##$STRIP}" | |
34 # [ -d "$subdir" ] && { | |
35 # grep -i "${X_GOPHER_SEARCH}" "$subdir/index.gph" | grep… | |
36 # } | |
37 #done | |
38 |