I have the following data in a set of files I need to look at and evaluate:
the file has a header row, and is delimited by <fsp> (wierd, I know)
I'm looking to see if the number of rows with an TimeInventoryUptime value between the file creation date and that same date +24 hrs is the same as the line count from a another file.
---------------- Begin Data Sample --------------------
NetworkElementID<fsp>DetailedInventory<fsp>TimeAdded<fsp>TimeDiscovered
<fsp>TimeDiscoveryChecked<fsp>TimeLastPolled<fsp>TimeLastEvent<fsp>
TimeConfigUpdated<fsp>TimeConfigChecked<fsp>TimeInventoryUptime<fsp>
TimeInventoryChecked<fsp>TimeFullInventoryUpdated<fsp>UptimeTimestamp<fsp>
TimeLastBoot<fsp>UptimeAtChassisChange<fsp>TimeDeleted
10.167.105.133<fsp><fsp>2008-10-28 12:41:11.633<fsp><fsp><fsp>2008-11-10 15:15:27.826<fsp><fsp>2008-11-10 15:15:36.670<fsp>2008-08-21 07:12:01.000<fsp>2008-11-10 15:15:27.826<fsp>2008-11-10 15:15:27.793<fsp>2008-11-07 19:29:58.693<fsp><fsp><fsp><fsp>
b-234-1<fsp><fsp>2008-10-28 12:41:12.183<fsp><fsp><fsp>2008-11-10 14:06:22.860<fsp><fsp>2008-11-10 15:12:43.896<fsp>2007-11-01 00:26:32.000<fsp>2008-11-10 14:06:22.860<fsp>2008-11-10 14:06:22.830<fsp>2008-11-07 19:29:58.923<fsp><fsp><fsp><fsp>
sacag13east-1<fsp><fsp>2008-10-28 12:41:12.333<fsp><fsp><fsp>2008-11-10 14:44:26.086<fsp><fsp>2008-11-10 15:19:01.120<fsp>2008-01-07 01:53:36.000<fsp>2008-11-10 14:44:26.086<fsp>2008-11-10 14:44:26.066<fsp>2008-11-07 19:29:59.126<fsp><fsp><fsp><fsp>
--------------- End Data Sample -------------------------
Here is what I have (please pardon the mess I'm kinda new at shell coding):
------------- Begin Code -------------------------
#!/bin/sh
## Variable declaration
tgFile=""
oscount=""
eiicount=""
eiiFileDate=""
echo "Please enter the file to check:"
read tgfile
unzip "$tgFile" 'out/OperatingSystem.download' -do /home/rlevau/download/
unzip "$tgFile" 'out/ElementInventoryInfo.download' -do /home/rlevau/download/
eiiFileDate=`ls -l /home/rlevau/download/out/ElementInventoryInfo.download | awk '{print $6,$7}'`
oscount$=`wc -l /home/rlevau/download/out/OperatingSystem.download`
eiicount=ElementCount(eiiFileDate)
if oscount=eiicount
then
cp $tgfile /home/rlevau/holding/$tgfile
fi
ElementCount (FileDate)
{
CountofElements=0
file="/home/rlevau/download/out/ElementInventoryInfo.download"
string=""
search="<fsp>"
do while not eof
nawk -f
string=getline $file
n=split(string,array,search)
if TimeInventoryUptime -ge `date '+%b %e'` and -le `date '+%b %e'` + 24
then CountOfElements=CountOfElements+1
fi
loop
Return CountOfElements
}
------------- End Code ---------------------------------
Thanks In advance
the file has a header row, and is delimited by <fsp> (wierd, I know)
I'm looking to see if the number of rows with an TimeInventoryUptime value between the file creation date and that same date +24 hrs is the same as the line count from a another file.
---------------- Begin Data Sample --------------------
NetworkElementID<fsp>DetailedInventory<fsp>TimeAdded<fsp>TimeDiscovered
<fsp>TimeDiscoveryChecked<fsp>TimeLastPolled<fsp>TimeLastEvent<fsp>
TimeConfigUpdated<fsp>TimeConfigChecked<fsp>TimeInventoryUptime<fsp>
TimeInventoryChecked<fsp>TimeFullInventoryUpdated<fsp>UptimeTimestamp<fsp>
TimeLastBoot<fsp>UptimeAtChassisChange<fsp>TimeDeleted
10.167.105.133<fsp><fsp>2008-10-28 12:41:11.633<fsp><fsp><fsp>2008-11-10 15:15:27.826<fsp><fsp>2008-11-10 15:15:36.670<fsp>2008-08-21 07:12:01.000<fsp>2008-11-10 15:15:27.826<fsp>2008-11-10 15:15:27.793<fsp>2008-11-07 19:29:58.693<fsp><fsp><fsp><fsp>
b-234-1<fsp><fsp>2008-10-28 12:41:12.183<fsp><fsp><fsp>2008-11-10 14:06:22.860<fsp><fsp>2008-11-10 15:12:43.896<fsp>2007-11-01 00:26:32.000<fsp>2008-11-10 14:06:22.860<fsp>2008-11-10 14:06:22.830<fsp>2008-11-07 19:29:58.923<fsp><fsp><fsp><fsp>
sacag13east-1<fsp><fsp>2008-10-28 12:41:12.333<fsp><fsp><fsp>2008-11-10 14:44:26.086<fsp><fsp>2008-11-10 15:19:01.120<fsp>2008-01-07 01:53:36.000<fsp>2008-11-10 14:44:26.086<fsp>2008-11-10 14:44:26.066<fsp>2008-11-07 19:29:59.126<fsp><fsp><fsp><fsp>
--------------- End Data Sample -------------------------
Here is what I have (please pardon the mess I'm kinda new at shell coding):
------------- Begin Code -------------------------
#!/bin/sh
## Variable declaration
tgFile=""
oscount=""
eiicount=""
eiiFileDate=""
echo "Please enter the file to check:"
read tgfile
unzip "$tgFile" 'out/OperatingSystem.download' -do /home/rlevau/download/
unzip "$tgFile" 'out/ElementInventoryInfo.download' -do /home/rlevau/download/
eiiFileDate=`ls -l /home/rlevau/download/out/ElementInventoryInfo.download | awk '{print $6,$7}'`
oscount$=`wc -l /home/rlevau/download/out/OperatingSystem.download`
eiicount=ElementCount(eiiFileDate)
if oscount=eiicount
then
cp $tgfile /home/rlevau/holding/$tgfile
fi
ElementCount (FileDate)
{
CountofElements=0
file="/home/rlevau/download/out/ElementInventoryInfo.download"
string=""
search="<fsp>"
do while not eof
nawk -f
string=getline $file
n=split(string,array,search)
if TimeInventoryUptime -ge `date '+%b %e'` and -le `date '+%b %e'` + 24
then CountOfElements=CountOfElements+1
fi
loop
Return CountOfElements
}
------------- End Code ---------------------------------
Thanks In advance