From e397980803cfa103524ec83abfc6f1a1b0445976 Mon Sep 17 00:00:00 2001 From: Morgan Date: Sat, 12 Oct 2019 16:55:38 +0200 Subject: [PATCH] add feature for filtering top results --- top_authors.sh | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/top_authors.sh b/top_authors.sh index bf6de24..42bf92d 100755 --- a/top_authors.sh +++ b/top_authors.sh @@ -1,3 +1,14 @@ -#/usr/bin/env bash -BASEDIR=$(dirname "$0") -grep http "$BASEDIR/README.md" | cut -d '[' -f 2 | cut -d ']' -f 1 | sed 's/\*//g' | grep -v "/" | sort | uniq -c | sort -n +#!/usr/bin/env bash +set -o errexit +set -o nounset +set -o pipefail + +function fetch_top_authors() { + local basedir + local filter + basedir=$(dirname "$0") + filter="${1:-}" + + grep http "$basedir/README.md" | grep "${filter}" | cut -d '[' -f 2 | cut -d ']' -f 1 | sed 's/\*//g' | grep -v "/" | sort | uniq -c | sort -n +} +fetch_top_authors "$@"