Sponsored Content
Full Discussion: Formatting the output
Top Forums Shell Programming and Scripting Formatting the output Post 15298 by Cameron on Tuesday 12th of February 2002 05:45:37 PM
Old 02-12-2002
Formatting the output

Hi all,

Have the following code(1) producing the results(2 & 3).
Would like to know if there is a way to format the two reports created in a similar fashion.
IE - The first is formatted nicely as a result of the echo "$xmpbdate $xavgs" >> $xmpbrpt
However when I attempt to do the same on the second report, I don't get the desired formatted result.

The Create_Report Function:
Code:
function Create_Report {

  ## Set Std Report File Name.
  xmpbrpt=$xrptdir$2
  ##
  ## Create Header.
  echo "SYSTEM: "`hostname`" (EVEREST-AU)" > $xmpbrpt
  echo "MPSAR(-b) Report (Daily Averages) - "$3", "`echo $2 | cut -c4-7`"."\
        >> $xmpbrpt
  echo "--------------------------------------------------------" >> $xmpbrpt
  echo "- Fields: Date, bread/s, lread/s, %rcache, bwrit/s," >> $xmpbrpt
  echo "-         lwrit/s, %wcache, pread/s, pwrit/s" >> $xmpbrpt
  echo "--------------------------------------------------------" >> $xmpbrpt
  for xmpbfile in $1$2/mpb??
    do
      #-- Get Date of SAR report -----------------------------#
      xmpbmm=`awk '/SCO_SV/' $xmpbfile | cut -c33-34`
      xmpbdd=`awk '/SCO_SV/' $xmpbfile | cut -c36-37`
      xmpbyy=`awk '/SCO_SV/' $xmpbfile | cut -c39-42`
      xmpbdate="$xmpbdd/$xmpbmm/$xmpbyy"
      #-- Get Average Values For The Day ---------------------#
      xavgs=`awk '/Average/' $xmpbfile | sed s/Average//`
      #-- Write details to report ----------------------------#
      echo $xmpbdate $xavgs >> $xmpbrpt
    done  ## End-of (for xmpbfile in $1$2/mpb??)
  echo "--------------------------------------------------------" \
        >> $xmpbrpt
  echo "End-of-Report." >> $xmpbrpt
  echo  >> $xmpbrpt
  #-- Secure Report to operator:group --------------------#
  chown operator:group $xmpbrpt
  chmod 644 $xmpbrpt
  #-- Send Email of Std Report ---------------------------#
  SendEmail $xmpbrpt $4 $3 `echo $2 | cut -c4-7`

  ## Set Detail Report File Name.
  xmpbrpt2=$xrptdir$2.detail
  echo "SYSTEM: "`hostname`" (EVEREST-AU)" > $xmpbrpt2
  echo "MPSAR(-b) Report (Detail) - "$3", "`echo $2 | cut -c4-7`"."\
        >> $xmpbrpt2
  echo "--------------------------------------------------------" >> $xmpbrpt2
  echo "- Fields: Date, time, bread/s, lread/s, %rcache, bwrit/s," >> $xmpbrpt2
  echo "-         lwrit/s, %wcache, pread/s, pwrit/s" >> $xmpbrpt2
  echo "--------------------------------------------------------" >> $xmpbrpt2
  for xmpbfile in $1$2/mpb??
    do
      #-- Get Date of SAR report -----------------------------#
      xmpbmm=`awk '/SCO_SV/' $xmpbfile | cut -c33-34`
      xmpbdd=`awk '/SCO_SV/' $xmpbfile | cut -c36-37`
      xmpbyy=`awk '/SCO_SV/' $xmpbfile | cut -c39-42`
      xmpbdate="$xmpbdd/$xmpbmm/$xmpbyy"
      #-- Get Detail Values for each Day ---------------------#
      #-- Write details to report ----------------------------#
      grep ":" $xmpbfile | grep -v "/" > $xmpbfile.temp
      while read xdetail; do
        echo "$xmpbdate $xdetail" >> $xmpbrpt2
      done < $xmpbfile.temp
      rm $xmpbfile.temp
    done  ## End-of (for xmpbfile in $1$2/mpb??)
  echo "--------------------------------------------------------" >> $xmpbrpt2
  echo "End-of-Report." >> $xmpbrpt
  #-- Secure Report to operator:group --------------------#
  chown operator:group $xmpbrpt2
  chmod 644 $xmpbrpt2

}  ## End-of-function Create_Report

The first report ...
Code:
TVL-AU: more Feb2002
SYSTEM: www3.???.???.?? (EVEREST-AU)
MPSAR(-b) Report (Daily Averages) - February, 2002.
--------------------------------------------------------
- Fields: Date, bread/s, lread/s, %rcache, bwrit/s,
-         lwrit/s, %wcache, pread/s, pwrit/s
--------------------------------------------------------
01/02/2002      1054   25865      96      62    1034      94       0       0
02/02/2002       870   44753      98     121     910      87       0       0
03/02/2002       743   45874      98      41     795      95       0       0
04/02/2002       998   26118      96      60     997      94       0       0
05/02/2002       952   27444      97      66    1021      94       0       0
06/02/2002      1185   26738      96      62    1014      94       0       0
07/02/2002      1020   49439      98      55     875      94       0       0
08/02/2002      1088   63444      98      57    1126      95       0       0
09/02/2002       292   14215      98     262     722      64       0       0
10/02/2002      1256   47739      97      42     846      95       0       0
11/02/2002      1209   30135      96      77    1154      93       0       0
12/02/2002      1459   30633      95      73    1149      94       0       0
--------------------------------------------------------
End-of-Report.

And a portion of the second report...
Code:
TVL-AU: more Feb2002.detail
SYSTEM: www3.???.???.?? (EVEREST-AU)
MPSAR(-b) Report (Detail) - February, 2002.
--------------------------------------------------------
- Fields: Date, time, bread/s, lread/s, %rcache, bwrit/s,
-         lwrit/s, %wcache, pread/s, pwrit/s
--------------------------------------------------------
01/02/2002 00:15:00 830 27654 97 170 3237 95 0 0
01/02/2002 00:30:00 39 10254 100 22 199 89 0 0
01/02/2002 00:45:00 28 9464 100 20 141 86 0 0
01/02/2002 01:00:00 27 8875 100 13 115 89 0 0
01/02/2002 01:15:00 499 67004 99 57 10206 99 0 0
01/02/2002 01:30:00 356 72201 100 119 7384 98 0 0

Any help greatfully appreciated.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

formatting output

Hi need some advice.. #grep -i hostname test.csv (gives the below output) HOSTNAME,name,host_test,,,,,,,, Now I need to format the above output as below. HOSTNAME: name=host_test Any easy way of doing this using awk or sed or printf? (4 Replies)
Discussion started by: balaji_prk
4 Replies

2. Shell Programming and Scripting

Formatting Output

Hi I tried running the below awk 'BEGIN { printf ("%s %-51s %s %-7s %s",$var1,$var2,$var3,$var4,$var5)}' from the command prompt and it is not working. Getting the error awk: Field $() is not correct. The source line number is 1. Actually my requirement is to form a string based on... (6 Replies)
Discussion started by: dhanamurthy
6 Replies

3. Shell Programming and Scripting

more help with formatting ls output...

Ok, for a fun project, my goal is to replicate the style of "catalog" on an old apple ] *A 002 SOMEAPPLESOFTFILE B 004 SOMEFILE T 006 SOMETEXT I 002 SOMEINTEGERFILE The first character is either " " or "*" depending on if the file is locked or not. Next is the filetype, so in... (1 Reply)
Discussion started by: patrick99e99
1 Replies

4. Shell Programming and Scripting

Formatting ls output

I am using find and ls to search for "warez" files on my server. find /home/ -regex ".*\.\(avi\|mp3\|mpeg\|mpg\|iso\)" -print0 | xargs -0 ls -oh This command produces this: -rw-r--r-- 1 1000 3.2M Feb 18 2009 /home/user/public_html/lupus.mp3 I want to only get this 3.2M... (4 Replies)
Discussion started by: bonrad
4 Replies

5. Shell Programming and Scripting

formatting output

Sorry for being a n00b, but I'm having a lot more trouble than I should with formatting the output to the program I finally completed. I'm basically looking for the linux equivalent to setw( ) from c++ so that I can print things in columns like this (but without the underlines lol): MISSPELLED: ... (4 Replies)
Discussion started by: aikaterinimak
4 Replies

6. Shell Programming and Scripting

Formatting of output

Hi Experts, I have to create a report for certain audit and my output looks as follows I m trying to format my output to look like Any inputs would be highly appreciated Thanks Syed (5 Replies)
Discussion started by: maverick_here
5 Replies

7. Shell Programming and Scripting

Output Formatting

Hi Guys I need help removing some lines from output i am receiving from a shell script. Here is the output: http://i52.tinypic.com/10z0fut.png I am trying to remove the output that i have circled. . ${EDW}/extracts/bin/extracts_setup2.sh . ${EDW}/extracts/extracts.conf ... (7 Replies)
Discussion started by: mooey1232003
7 Replies

8. Shell Programming and Scripting

Formatting the output

Hi, I have a file which contents entries in this form. Only in /data4/temp abc.000001 Only in /data4/temp abc.000003 Only in /data4/temp abc.000012 Only in /data4/temp abc.000120 Only in /data4/temp abc.000133 Only in /data4/temp abc.001444 i want to read line by line and format... (2 Replies)
Discussion started by: arijitsaha
2 Replies

9. AIX

Help Formatting Output

I am using FORTRAN 90 on AIX 5.3 and need to output my data to a tab-delimited file. It must have actual tabs, and I cannot figure out a way to make it work. The resulting file will be imported into another application (quickbooks) as an .iif file....for some reason, it needs the tabs; spaces do... (2 Replies)
Discussion started by: KathyB148
2 Replies

10. Shell Programming and Scripting

Formatting the Output

Hi, I am trying to use printf command and format certain output in a specific format as under: While the left side (upto |) of the above format is part of a fixed header function, the right side is where i am expecting data to be printed. However, as seen, Row1 value is reflecting on last... (5 Replies)
Discussion started by: EmbedUX
5 Replies
All times are GMT -4. The time now is 08:34 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy