diff options
author | KatolaZ <[email protected]> | 2020-01-12 18:34:13 +0000 |
---|---|---|
committer | KatolaZ <[email protected]> | 2020-01-12 18:34:13 +0000 |
commit | b50158a8f3d1ae29658206a4d591426a51df3e28 (patch) | |
tree | 1b43f8745e95e604a502947aadb31121e755a3b2 /search_repo | |
parent | 7acd17b36e16815a1a4f0e304e1ed979b2bdded0 (diff) |
Add static index files
- index_repo creates them
- search_repo now looks for those indices
Diffstat (limited to 'search_repo')
-rwxr-xr-x | search_repo | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/search_repo b/search_repo index ed9562d..05409ce 100755 --- a/search_repo +++ b/search_repo @@ -5,6 +5,11 @@ # to the matching repos # + +REPOIDX="repo_idx.txt" +DSCRIDX="descr_idx.txt" +RDMEIDX="readme_idx.txt" + if [ $# -lt 2 ]; then printf "Usage: %s <dir> <word> [<word>...]\n" $0 exit 1 @@ -18,16 +23,12 @@ query=$(echo "$WORDS" | sed -E 's/\ /\|/g') cd "$FOLDER" -reponames=$(find ./ -type d | grep -E "\/.*\/" | grep -Ei "$query" | \ - sed -E 's/.\/([a-z]+)\//\1:\/\//1') - -descrfiles=$(find ./ -type f -name 'DESCR' | tr '\n' ' ') -repodescr=$(grep -Eic "$query" ${descrfiles} | grep -v ":0$" | sort -t ':' -rnk2 | \ - sed -E 's/^\.\///;s/([a-z]+)\//\1:\/\//1;s/\/[^\/]*$//' ) +reponames=$( grep -Ei "$query" $REPOIDX) +repodescr=$(grep -Eic "$query" $(cat $DSCRIDX) | grep -v ":0$" | sort -t ':' -rnk2 | \ + sed -E 's/^\.\///;s/([a-z]+)\//\2:\/\//1;s/\/[^\/]*$//' ) -readmefiles=$(find ./ -type f -iname 'readme*' | tr '\n' ' ') -readmes=$(grep -Eic "$query" ${readmefiles} | grep -v ":0$" | sort -t ':' -rnk2 | \ +readmes=$(grep -Eic "$query" $(cat $RDMEIDX) | grep -v ":0$" | sort -t ':' -rnk2 | \ sed -E 's/^\.\///;s/([a-z]+)\//\1:\/\//1;s/\/[^\/]*$//' ) |