Skip to content

Instantly share code, notes, and snippets.

@milovtim
Last active January 30, 2019 10:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save milovtim/fb5e6c90cf88857c760ae1e1fb7892bd to your computer and use it in GitHub Desktop.
Save milovtim/fb5e6c90cf88857c760ae1e1fb7892bd to your computer and use it in GitHub Desktop.
Grap keys from bunch of .properties files with keys with [a-z _ .]
#!/usr/bin/env bash
# files with prop keys on each line
KEYS_FILE="/path/to/result.list"
# Extract keys to file
awk -F = '/^[a-z_.]+=/ { print $1 }' /some/path/files > "$KEYS_FILE"
# path to some repo
SEARCH_PATH="/path/to/repo"
# Search each prop key in given folder with exclusions
while IFS='' read -r line || [[ -n "$line" ]];
do
echo "Parse $SEARCH_PATH for $line"
RESULT=$(fgrep "$line" \
--exclude .git/** \
--exclude binaries/** \
--recursive \
"$SEARCH_PATH")
if [[ -n "$RESULT" ]]
then
echo "$RESULT" > "results/${line}.result"
fi
done < "$KEYS_FILE"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment