Skip to content

Instantly share code, notes, and snippets.

@arbakker
Created December 13, 2022 16:46
Show Gist options
  • Save arbakker/a309317cde70c264e01fc65049f10348 to your computer and use it in GitHub Desktop.
Save arbakker/a309317cde70c264e01fc65049f10348 to your computer and use it in GitHub Desktop.
Check broken links markdown
#!/usr/bin/env bash
# npm install --save-dev markdown-link-check -g
total=0
broken=0
rm -f broken-links.log
for file in $(find . -type f -name "*.md" | grep -v ".gitea")
do
file=$(realpath $file)
logging=$(markdown-link-check --verbose "$file" 2>&1)
if [[ $? -eq 1 ]] ;then
echo "$logging" >> broken-links.log
echo "BROKEN LINK(S) IN: ${file}"
broken=$((broken+1))
fi
total=$((total+1))
done
echo "broken links in ${broken}/${total} markdown files"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment