im using this command to return the number of links in my directory,
grep -c -i -h "href" *html */*html *htm *shtml
is there a way of adding these to get the total?
Cheers
im using this command to return the number of links in my directory,
grep -c -i -h "href" *html */*html *htm *shtml
is there a way of adding these to get the total?
Cheers
There might be a far easier way but try a script something like
#! /bin/sh
total=0
grep -cih "href" *html */*html *htm *shtml > countfile
for num in `cat countfile`
{
total=`expr $total + $num`
}
echo total
grep -c -i -h "href" *html */*html *htm *shtml 2>> /dev/null |\
awk 'BEGIN {t=0} {t+=int($1)} END {printf "%ld\n", t}'
Only problem with the grep -c, it'll count the number of lines (not occurences), so if you have a html file with more than one href per line (very probable) you won't get your number right
If a html file contains:
<a href=....>link1</a><a href=....>link3</a><a href=....>link3</a>
... your grep will return only 1 instead of the expected 3.