From b2318bae725de4055c0466e3f1858f51b22e37fe Mon Sep 17 00:00:00 2001 From: Ethan Morgan Date: Fri, 13 Feb 2026 14:58:57 +0000 Subject: add scripts --- sisc | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100755 sisc (limited to 'sisc') diff --git a/sisc b/sisc new file mode 100755 index 0000000..137bd48 --- /dev/null +++ b/sisc @@ -0,0 +1,45 @@ +#!/bin/sh + +# Some weird script to find a word + +if [ $# -lt 1 ]; then + echo "Usage: $0 [search_directory] [ignored_dir1] [ignored_dir2] ..." >&2 + exit 1 +fi + +WORD="$1" +shift + +DIR="${1:-.}" +shift + +if [ ! -d "$DIR" ]; then + echo "Error: Directory '$DIR' does not exist." >&2 + exit 1 +fi + +IGNORED_DIRS="" +while [ $# -gt 0 ]; do + IGNORED_DIR="$1" + # Construct prune conditions + if [ -z "$IGNORED_DIRS" ]; then + IGNORED_DIRS="-path \"$DIR/$IGNORED_DIR\" -prune" + else + IGNORED_DIRS="$IGNORED_DIRS -o -path \"$DIR/$IGNORED_DIR\" -prune" + fi + shift +done + +if [ -n "$IGNORED_DIRS" ]; then + FIND_COMMAND="find \"$DIR\" $IGNORED_DIRS -o -type f -print" +else + FIND_COMMAND="find \"$DIR\" -type f" +fi + +eval "$FIND_COMMAND" | while read -r file; do + if grep -q "$WORD" "$file" 2>/dev/null; then + grep -n "$WORD" "$file" 2>/dev/null | while IFS=: read -r linenum line; do + printf "%s:%d - %s\n" "$file" "$linenum" "$(echo "$line" | sed 's/^ *//')" + done + fi +done -- cgit v1.2.3