summaryrefslogtreecommitdiff
path: root/search_repo
diff options
context:
space:
mode:
authorKatolaZ <katolaz@freaknet.org>2020-01-08 07:45:14 +0000
committerKatolaZ <katolaz@freaknet.org>2020-01-08 07:45:14 +0000
commitbc3a1f13fd5fddb9fa8f3ecff6144b512ed9d08b (patch)
treeccff9f0741a92a65f5aebd3d9c155aa6868bfe45 /search_repo
initial commit
Diffstat (limited to 'search_repo')
-rwxr-xr-xsearch_repo24
1 files changed, 24 insertions, 0 deletions
diff --git a/search_repo b/search_repo
new file mode 100755
index 0000000..65dd9c5
--- /dev/null
+++ b/search_repo
@@ -0,0 +1,24 @@
+#!/bin/sh
+
+#
+# Search a set of repos for specific words and return a list of URLS
+# to the matching repos
+#
+
+if [ $# -lt 2 ]; then
+ printf "Usage: %s <dir> <word> [<word>...]\n" $0
+ exit 1
+fi
+
+FOLDER="$1"
+shift
+WORDS="$@"
+
+query=$(echo "$WORDS" | sed -E 's/\ /\|/g')
+
+cd "$FOLDER"
+
+res=$(grep -Eric "$query" | grep -v ":0$" | sort -t ':' -rnk2 | \
+ sed -E 's/([a-z]+)\//\1:\/\//1;s/\/[^\/]*$//' )
+
+echo "$res" | grep -Ei "^[a-z]+://"