summaryrefslogtreecommitdiff
path: root/search_repo
blob: 65dd9c5eddceb15023f6b02641623a0afca85b8d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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]+://"