CountMsgsByDay script

Discussions on Python, Bash, Perl, etc.
Post Reply
Mick Lang

CountMsgsByDay script

Post by Mick Lang » Mon May 22, 2017 12:05 pm

#!/bin/sh -f

##########################################################################
# CountMsgsByDay Script-- this will count all incoming messages for a given time period
##########################################################################

echo "This script will calculate the total number of incoming"
echo "messages for input comms. Please enter the year you would like:"
echo "Year (example: 2016):"; read YEAR
echo " "
echo "Now enter the month:"
echo "MONTH (example: 02 for February):"; read MONTH
echo " "
echo "Now enter the day:"
echo "DAY (example: 02 for the second):"; read DAY

MSGDIR="/var/opt/j**x/msgs"
COMMLISTIN="CommsA/in CommsB/in CommsC/in CommsD/in"

For COMMO in $COMMLISTIN
do
NumMsg="0"
for MONTH in $MONTH
do
if [ -d ${MSGDIR}/{COMMO}/${YEAR}/${DAY} ]
then

NumMsg=`ls -R ${MSGDIR}/{COMMO}/${YEAR}/${MONTH}/${DAY} | wc -l`

fi
done
echo $COMMO : ${YEAR}/${MONTH}/${DAY} : $NumMsg messages[/list]
done

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest