-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfindcheatcodes.sh
More file actions
executable file
·38 lines (29 loc) · 846 Bytes
/
findcheatcodes.sh
File metadata and controls
executable file
·38 lines (29 loc) · 846 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/bash
# Display usage
if [ $# -ne 1 ]; then
echo "Usage: $0 <search_directory>"
exit 1
fi
# Define the file containing the list of cheatcodes
CODE_LIST_FILE="cheatcodes.txt"
# Define the directory to search
SEARCH_DIR="$1"
# Array store for found cheatcodes
declare -a found_codes=()
# Read each cheatcode and search the desired repo for it
while IFS= read -r cheatcode || [ -n "$cheatcode" ]; do
# Skip empty lines
if [ -z "$cheatcode" ]; then
continue
fi
# Remove any trailing carriage return or whitespace
cheatcode=$(echo "$cheatcode" | tr -d '\r' | xargs)
if grep -riq "$cheatcode" "$SEARCH_DIR"; then
found_codes+=("$cheatcode")
fi
done < "$CODE_LIST_FILE"
# Output found cheatcodes
echo "Found cheatcodes: "
echo ""
printf '%s\n' "${found_codes[@]}" | sort -u
echo ""