#!/usr/bin/env sh# Exit on errorset -e# Check if at least 2 arguments (path and one word)if [ $# -lt 2 ]; then echo "Usage: $0 <directory> <word1> [word2] ..." exit 1fi# Check if directory existsif [ ! -d "$1" ]; then echo "Error: Directory $1 not found" exit 1fi# Get directory and shift to remove it from argsdir="$1"shift# Create pattern from remaining argspattern=$(printf "%s\|" "$@" | sed 's/\\|$//')find "${dir}" -name "*.md" -exec grep -l "${pattern}" {} +
#!/usr/bin/env sh# Exit on errorset -e# Check if both arguments are providedif [ $# -ne 2 ]; then echo "Usage: $0 <directory> <stopwords-file>" exit 1fi# Check if directory existsif [ ! -d "$1" ]; then echo "Error: Directory $1 not found" exit 1fi# Check if stopwords file existsif [ ! -f "$2" ]; then echo "Error: Stopwords file $2 not found" exit 1fifind "${1}" -name "*.md" -exec cat {} + | tr '[:upper:]' '[:lower:]' | tr -cs '[:lower:]' '\n' | grep -v -w -f "$2" | sort | uniq -c | sort -rn