Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

nawk functionality (API) in java?  RSS feed

Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anyone tell me if there is a java api that duplicates the functionality provided in the Nawk utility? I am trying to retrieve Unix Server statisitics, reformat the output and load that file into Oracle. I am using the unix sar command to read a system accounting file (named sa24 created on Oct 24) located in /usr/adm/sa. I pipe the output to nawk and use the C printf program to format the output. I have a sample someone else wrote in Korn shell, but I do not know Korn shell and would like to do the same thing in a java program. Some manipulation that needs to be done to the output is delete lines with spaces, header lines and a row showing averages to load just the raw data (numbers) into each Oracle record.
Here is the syntax for what I described above.
sar -u -f sa24|nawk '{printf "%5s %5s %5s %5s %5s\n",$1,$2,$3,$4,$5}'\
Sample output:
SunOS cero 5.8 Generic_108528-13 sun4u

00:00:01 %usr %sys %wio %idle
01:00:00 17 7 40 36
{the output includes statistics for every hour}
23:00:00 2 7 68 23

Average 11 8 59 22
I found an api for Java that dupicates the printf C functionality at
Any feedback would be greatly appreciated.
Thank you
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!