#!/bin/bash




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

wrong=0
for line in $check; do
#echo $line

pathtocheck=$(dirname $file)/$line


if [ -f $(dirname $file)/$line ]; then
	:
	#echo "ok $pathtocheck"
else
	if [ $wrong -eq "0" ]; then
		echo ""
		echo "\n+++++ $file +++++\n"
	fi
	wrong=1
#	echo "wrong link in $(readlink -m $pathtocheck)"
	echo "wrong link in $pathtocheck"

fi
done
fi
done
echo ""