dotfiles/.bin/port-search
2024-12-31 10:47:38 +01:00

26 lines
503 B
Bash
Executable File

#!/bin/sh -x
if [ -z "$1" ]
then
echo "usage: port-search [file pattern] <search term>"
exit 2
fi
if [ -n "$2" ]
then
_filter="-iname *$1*" \
_term="$2"
else
_term="$1"
fi
find /usr/ports/ \
-not \( -path "/usr/ports/pobj" -prune \
-o -path "*/distfiles" -prune \
-o -path "*/packages" -prune \
-o -path "*/logs" -prune \
-o -path "*/CVS" -prune \
\) \
-type f \
$_filter \
-exec ugrep -i -F -- "$_term" {} +