writing
mostly bash/gitbash-compliant ports of Python scripts to have some automations on restricted Windows machines
find bold text (**) in markdown files
find . -type f -name "*.md" | while read -r file; do
grep -oE '\*\*[^*]+\*\*' "$file" \
| sed 's/^\*\*//; s/\*\*$//' \
| sort -u
done # > ./bold-phrases.txt
find Title Case phrases in markdown files
...with awk
!
Awk is around my age. And it's awesome. Give it some love (or at least give it some use).
Even wikipedia gives it a quick tutorial. Also check up on awk.info (last time I did, it's been for sale with some pretty ugly AI-generated images).
find . -type f -name "*.md" | while read -r file; do
grep -P '^[^#><*].*\b[A-Z][a-zA-Z]*\b' "$file" \
| awk '{
for (i=2; i<=NF; i++) {
if ($i ~ /^[A-Z][a-zA-Z]*$/) {
entry = $i;
while ((i+1)<=NF && $(i+1) ~ /^[A-Z][a-zA-Z]*$/) {
entry = entry " " $(i+1);
i++;
}
print entry;
}
}
}' \
| sort -u
done
populate/replace Alt text for images in markdown files
requires a csv:
filename,alt_text
main-config.png,Screenshot of the main configuration screen
...
Basically a wrapper for sed (with -E to ensure proper handling of escapes in pattern)
Last updated