Re: Shell Script Pointers?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



I have written my script but I wanted to add this on before and after
the update to see the difference but all it returns are zeros? Anyone
have any idea why?

#!/bin/sh

f=0 #Folder count
d=0 #Domains count (one per line in each file)
u=0 #Url count (one per line in each file)
t=0 #Total of domains and urls
x=0 #Temporary variable for calculations

find /usr/local/squidGuard/db -maxdepth 1 -type d | while read FOLDER; do
        f=`expr $f + 1`
        if [ -f $FOLDER/domains ]; then
                x=`wc -l $FOLDER/domains | awk '{print $1}'`
                d=`expr $d + 1`
        fi
        if [ -f $FOLDER/urls ]; then
                x=`wc -l $FOLDER/urls | awk '{print $1}'`
                u=`expr $u + 1`
        fi
done

t=`expr $d + $u`

echo "Number of categories: $f"
echo "Number of domains: $d"
echo "Number of URLs: $u"
echo "Total entries: $t"
echo "$x"



This is the ouput:

[hades@hades ~]$ sh tester
Number of categories: 0
Number of domains: 0
Number of URLs: 0
Total entries: 0
0
[hades@hades ~]$

Many thanks, James ;)



-----BEGIN GEEK CODE BLOCK-----
  Version: 3.1
GIT/MU/U dpu s: a--> C++>$ U+> L++> B-> P+> E?> W+++>$ N K W++ O M++>$ V-
PS+++ PE++ Y+ PGP t 5 X+ R- tv+ b+> DI D+++ G+ e(+++++) h--(++) r++ z++
------END GEEK CODE BLOCK------
_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos

[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux