hello. this is the code
#!/bin/sh
total1024=0
total2048=0
total8192=0
if [ $# -eq 1 ] ; then
if [ -e "$1" ] ; then
while read variable
do
if [ echo "$variable | cut -f 2 -d/" = 1024 ] ; then
total1024=$(( $total1024 + 1 ))
fi
if [ echo "$variable | cut -f 2 -d/" = 2048 ] ; then
total2048=$(( $total2048 + 1 ))
fi
if [ echo "$variable | cut -f 2 -d/" = 8192 ] ; then
total8192=$(( $total8192 + 1 ))
fi
done
echo "$total1024"
echo "$total2048"
echo "$total8192"
else
echo "Wrong file name."
break
fi
elif [ $# -eq 0 ] ; then
echo "No parameter was given."
break
else
echo "Too many parameters."
break
fi
the external is this
John Papadakis/8192/Kavala
Peter O Toul/2048/Thessaloniki
John Pepas/1024/Thessaloniki
Tasos K/8192/Kilkis
Jason F/1024/Kozani
Telis G/2048/Serres
Mimis A/2048/Kavala
i want to count the 1024,2048 and 8192 connections and echo the total sum of each one.. for example total8192 = 2
total1024 = 2
total2048 = 3
the code is not right.. i think the problem is at these parts..
if [ echo "$variable | cut -f 2 -d/" = 1024 ] ; then
if [ echo "$variable | cut -f 2 -d/" = 2048 ] ; then
if [ echo "$variable | cut -f 2 -d/" = 8192 ] ; then
some help please? anyhelp will be appreciated