Last active
July 11, 2019 13:35
-
-
Save tmclnk/936a11772a840f0b11ee392dea9a60e6 to your computer and use it in GitHub Desktop.
given a directory, recursively finds files which reference the (dbml) files in that directory
This file contains hidden or 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
# Checks for links to the files in a given directory by | |
# searching for each filename in every other file. | |
# For example, if "menu.dbml" has links to "page1.dbml" and "page2.dbml", | |
# then the output will print "menu.dbml", then show | |
# "page1.dbml" and "page2.dbml" underneath. | |
checklinks() { | |
if [ -z "$1" ]; then | |
dir=. | |
else | |
dir=$1 | |
fi | |
for f in $( find "$dir" -type f -iname "*.dbml" ); do | |
file=$(basename $f) | |
printf "%0.64s\n" "====== $f =========================================================================" | |
# add a -o flag here to show just the matching filename, | |
# omitting the rest of the line | |
grep -ir "$file" --exclude="$file" * --color=always 2>/dev/null | |
echo | |
done | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment