#!/bin/sh # ###################################################### # # Script: linkSort.sh # Description: Count and sort Google links # output by Google Webmaster Tools # # Copyright 2007 Apogee Web Consulting LLC # http://www.apogee-web-consulting.com # # This is open source code. # Use for personal or commercial use. # If you break it, fix it. # If it's already broken, fix it. # Enjoy! # ###################################################### # Check args case $# in 1) LINK_FILE="$1" ;; *) echo "usage: $0 Filename.csv"; exit ;; esac # Parse links file awk -F, '{print $1}' $LINK_FILE |grep http > /tmp/pagesAll.txt cat /tmp/pagesAll.txt | sort -u | \ while read page do echo $page `grep -c "$page" /tmp/pagesAll.txt` >> /tmp/pageCounts.txt done # Output results sed 's/\"//g' /tmp/pageCounts.txt |sort -n -k2 echo "========================" awk '{n+=$NF} END {print "total pages:",n}' /tmp/pageCounts.txt echo "unique pages: `wc -l /tmp/pageCounts.txt |awk '{print $1}'`" # Clean up rm /tmp/pageCounts.txt rm /tmp/pagesAll.txt