Created
November 22, 2024 19:09
-
-
Save apoorvalal/6bdb8ab5ef7b7dbe5692ccba099ccbeb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Directory to search | |
DIRECTORY=$1 | |
# Additional extensions to search, if provided | |
EXTENSIONS="tex" | |
if [ ! -z "$2" ]; then | |
EXTENSIONS="$EXTENSIONS|$2" | |
fi | |
# Check if directory is provided | |
if [ -z "$DIRECTORY" ]; then | |
echo "Usage: $0 <directory> [additional_extensions]" | |
exit 1 | |
fi | |
# Search pattern for common typos related to causal terms | |
PATTERN="\bcasual\b (infer|effec|quant)" | |
# Find files with the specified extensions in the directory and search for the pattern | |
find "$DIRECTORY" -regextype posix-egrep -regex ".*\.($EXTENSIONS)$" -print0 | while IFS= read -r -d '' file; do | |
echo "Searching in: $file" | |
grep -HinE "$PATTERN" "$file" | |
done |
Author
apoorvalal
commented
Nov 22, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment