Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combining Awk programs

Status
Not open for further replies.

Kipnep70

Technical User
Nov 18, 2003
81
0
0
US
I have a script that uses several awk one liners to manipulate data. Does it make sense to have several awk programs in one shell script, or is it always possible to combine the awk programs?

Example:

Code:
#Running bperror to get data
/usr/openv/netbackup/bin/admincmd/bperror -backstat -l -d ${sdate} -e ${sdate} | \

#Reverse output
awk '{store[NR]=$0}END{if(i=NR;i>=1;i--)print store[i]}' | \

#Getting Unique Entries
awk '{time=$1;client=$12;policy=$14;sched=$16;status=$19}!/Unable/{print time,client,policy,sched,status}'| \

awk '!x[$2,$3,$4]++' | \

#Filter Out Errors
awk '$5>1 && $5!=150 && $5!=191' | sort +4

Does it make sense to try to combine the above awk statements?
 
Typed, untested:
Code:
/usr/openv/netbackup/bin/admincmd/bperror -backstat -l -d ${sdate} -e ${sdate} | awk '
!/Unable/{time[NR]=$1;client[NR]=$12;policy[NR]=$14;sched[NR]=$16;status[NR]=$19}
END{for(i=NR;i>=1;i--)
  if(!x[client[i],policy[i],sched[i]]++ && status[i]>1 && status[i]!=150 && status[i]!=191)
    print time[i],client[i],policy[i],sched[i],status[i]
}' | sort +4

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top