pathcheck.sh 598 Bytes
Newer Older
1 2
#!/bin/bash

3
#the script controls links, only inside the whole directory, doesnt control outside pages
4 5

for file in $@; do
6
check=$(cat "$file" | grep -Po "\[.*?\]\([^ ]*?\)" | grep -v "#" | grep -vE "http|@|www|ftp|none" | sed 's/\[.*\]//g' | sed 's/[()]//g' | sed 's/\/$/.md/g')
7 8 9 10 11
if [ ! -z "$check" ]; then

wrong=0
for line in $check; do

12
pathtocheck=$(dirname "$file")/$line
13 14


15
if [ -f $(dirname "$file")/"$line" ]; then
16 17 18 19 20 21 22 23 24
	:
	#echo "ok $pathtocheck"
else
	if [ $wrong -eq "0" ]; then
		echo ""
		echo "\n+++++ $file +++++\n"
	fi
	wrong=1
	echo "wrong link in $pathtocheck"
Pavel Gajdušek's avatar
Pavel Gajdušek committed
25

26 27 28 29 30
fi
done
fi
done
echo ""