The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #5 (permalink)  
Old 06-05-2009
Franklin52 Franklin52 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,300
To get the date of yesterday you can use the datecalc script of Perderabo.
Place this script in the same directory of your script with the name datecalc and make it executable:

days elapsed between 2 dates

Your script should looks like:

Code:
#!/bin/ksh

dat=$(./datecalc -a $(date +"%Y %m %d") - 1)

day=$(/usr/xpg4/bin/awk -v d="$dat" 'BEGIN {split(d,a," ");day=sprintf("%s%02s%02s",a[1],a[2],a[3]);print day}')

/usr/xpg4/bin/awk -v d="$day" -v serv="BSNLSERVICE1" -v val="2128" '
$1 ~ day && $4==serv && $6==val {
  s1++;a[$14]++;b[$9]++
}
END{
  print "Filename: " FILENAME "\n"
  print serv,val, "=" s1 "\n"
  print serv,val, a["SUCCESS"]
  print serv,val, a["SYSTEM"] "\n"
  for(i in b){print i, b[i]} 
}' $day*
Bits Awarded / Charged to Franklin52 for this Post
Date User Comment Amount
06-06-2009 aemunathan Excellent work done 50,000