add internal link checker script
This commit is contained in:
parent
68996291d8
commit
620370f52b
16
internal_link_checker.sh
Executable file
16
internal_link_checker.sh
Executable file
@ -0,0 +1,16 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# used to alert me if i've written a bad internal link or broken one by changing a header
|
||||||
|
|
||||||
|
files="$(find $1 -name '*.html' -type f)"
|
||||||
|
|
||||||
|
for filename in $files
|
||||||
|
do
|
||||||
|
links="$(grep -oP '<a.*?>' -h $filename | grep -oP '(?<=href="\#).*?(?=")')"
|
||||||
|
ids="$(grep -oP '(?<=id=").*?(?=")' -h $filename)"
|
||||||
|
|
||||||
|
for link in $links
|
||||||
|
do
|
||||||
|
[[ "$ids" == *"$link"* ]] \
|
||||||
|
|| echo Found broken internal link in $filename: $link
|
||||||
|
done
|
||||||
|
done
|
Loading…
Reference in New Issue
Block a user