Skip to content
Snippets Groups Projects
Select Git revision
  • fea463c4bdee41f0f9fb3684bded97324b08bf71
  • master default protected
  • lifecycle
  • kru0052-master-patch-91081
  • chat
  • 20180621-revision
  • 20180621-before_revision
7 results

pathcheck.sh

Blame
  • pathcheck.sh 598 B
    #!/bin/bash
    
    #the script controls links, only inside the whole directory, doesnt control outside pages
    
    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
    
    wrong=0
    for line in $check; do
    
    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 $pathtocheck"
    
    fi
    done
    fi
    done
    echo ""