Tiny Tool: checkRefs.sh
while read -r referenced_String; do
matches=$(grep -Flsi "$referenced_String" *)
echo "## ${referenced_String}"
if [ -n "$matches" ]; then
echo "$matches"
else
echo "unreferenced"
fi
done
Used with ls -1 ../templates | sh ../checkRefs.sh
, this will check the files in the current directory to see which ones use a file from ../templates
I used this when building playbooks, to see which templates were used by files in the current directory – and which were unused. If a file referenced two templates, I could see that, too.
I built the tool because I did the work by hand a couple of times, and that became slow and error-prone as the number of files and strings increased. I couldn't find a way to make a tool (either on the commandline or within my IDE) do it. So it's tool time. Making it took about 15 minutes, and taught me some stuff – time well spent. Writing about making it has taken an hour.
I imagine I'll use it generally: I'll certainly use it on my current project again.
Subscribers get to see how I used LLMs Qwen3 and Claude3.7Sonnet.
Comments
Sign in or become a Workroom Productions member to read and leave comments.