Skip to content

Instantly share code, notes, and snippets.

@apoorvalal
Created November 22, 2024 19:09
Show Gist options
  • Save apoorvalal/6bdb8ab5ef7b7dbe5692ccba099ccbeb to your computer and use it in GitHub Desktop.
Save apoorvalal/6bdb8ab5ef7b7dbe5692ccba099ccbeb to your computer and use it in GitHub Desktop.
#!/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
@apoorvalal
Copy link
Author

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment