<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: scripting help in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/2604151#M853151</link>
    <description>Vito,&lt;BR /&gt;&lt;BR /&gt;Based on your output here is how you would get the last line from your file&lt;BR /&gt;&lt;BR /&gt;cat FILENAME | awk '{ print $5 }' &amp;gt; OUTPUT&lt;BR /&gt;&lt;BR /&gt;To use mathmatical formulas look at the expr command&lt;BR /&gt;&lt;BR /&gt;A simple example would be:&lt;BR /&gt;&lt;BR /&gt;AVG=`expr TOTAL/30`&lt;BR /&gt;&lt;BR /&gt;These should get you started down the right road.</description>
    <pubDate>Tue, 30 Oct 2001 16:59:48 GMT</pubDate>
    <dc:creator>Craig Rants</dc:creator>
    <dc:date>2001-10-30T16:59:48Z</dc:date>
    <item>
      <title>scripting help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/2604148#M853148</link>
      <description>I want to pull the last line out from a the sar report im running on a daily basisin cron.  I want to put this data to another file and concatenate each day for thirty days.&lt;BR /&gt;&lt;BR /&gt;I want to take the average line and totals and add each days average line to this file so that I have approximately a file with 30 days of my sar data in it?  &lt;BR /&gt;&lt;BR /&gt;I have a cron job that produces this report each day.  The output file it creates each day is called hostname_monthday.  example would be:&lt;BR /&gt;&lt;BR /&gt;system1_1029 for yesterdays output of this report.&lt;BR /&gt;&lt;BR /&gt;21:45:00       3       3       2      92&lt;BR /&gt;22:00:01       3       3       2      92&lt;BR /&gt;22:15:00       9       7      53      32&lt;BR /&gt;22:30:00       3       4      91       1&lt;BR /&gt;22:45:00       3       5      91       1&lt;BR /&gt;23:00:00       3       5      91       1&lt;BR /&gt;23:15:00       3       4      91       1&lt;BR /&gt;23:30:00       3       4      91       1&lt;BR /&gt;23:45:00       3       4      90       2&lt;BR /&gt;&lt;BR /&gt;Average       21       6      24      50&lt;BR /&gt;&lt;BR /&gt;How can I accomplish this?&lt;BR /&gt;&lt;BR /&gt;Please advise?&lt;BR /&gt;&lt;BR /&gt;Vito</description>
      <pubDate>Tue, 30 Oct 2001 16:50:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/2604148#M853148</guid>
      <dc:creator>Vito Sarducci</dc:creator>
      <dc:date>2001-10-30T16:50:26Z</dc:date>
    </item>
    <item>
      <title>Re: scripting help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/2604149#M853149</link>
      <description>how about&lt;BR /&gt;&lt;BR /&gt;tail -1 hostname_month &amp;gt;&amp;gt;collect_file&lt;BR /&gt;&lt;BR /&gt;tail -1 gets the last line and &amp;gt;&amp;gt; will append it to collect_file&lt;BR /&gt;&lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Tue, 30 Oct 2001 16:58:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/2604149#M853149</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2001-10-30T16:58:01Z</dc:date>
    </item>
    <item>
      <title>Re: scripting help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/2604150#M853150</link>
      <description>How about something like this:&lt;BR /&gt;LOG=$(date +%m).Summary&lt;BR /&gt;echo "$DATE &lt;BR /&gt;\c "&amp;gt;&amp;gt; $LOG&lt;BR /&gt;sar -f &lt;YESTERDAY&gt; |grep "Average" &amp;gt;&amp;gt; $LOG&lt;BR /&gt;&lt;BR /&gt;This would put a date and the average line from sar into a file called $LOG, i.e. monthy.Summary.  Just have to define the DATE variable.&lt;BR /&gt;&lt;BR /&gt;-Santosh&lt;BR /&gt;&lt;/YESTERDAY&gt;</description>
      <pubDate>Tue, 30 Oct 2001 16:59:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/2604150#M853150</guid>
      <dc:creator>Santosh Nair_1</dc:creator>
      <dc:date>2001-10-30T16:59:46Z</dc:date>
    </item>
    <item>
      <title>Re: scripting help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/2604151#M853151</link>
      <description>Vito,&lt;BR /&gt;&lt;BR /&gt;Based on your output here is how you would get the last line from your file&lt;BR /&gt;&lt;BR /&gt;cat FILENAME | awk '{ print $5 }' &amp;gt; OUTPUT&lt;BR /&gt;&lt;BR /&gt;To use mathmatical formulas look at the expr command&lt;BR /&gt;&lt;BR /&gt;A simple example would be:&lt;BR /&gt;&lt;BR /&gt;AVG=`expr TOTAL/30`&lt;BR /&gt;&lt;BR /&gt;These should get you started down the right road.</description>
      <pubDate>Tue, 30 Oct 2001 16:59:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/2604151#M853151</guid>
      <dc:creator>Craig Rants</dc:creator>
      <dc:date>2001-10-30T16:59:48Z</dc:date>
    </item>
    <item>
      <title>Re: scripting help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/2604152#M853152</link>
      <description>Hi Vito,&lt;BR /&gt;If I understand properly you need last line only. easy&lt;BR /&gt;#tail -1 filename &amp;gt;&amp;gt; outputfile&lt;BR /&gt;&lt;BR /&gt;But I think you that is not what you want because it is seems too easy. &lt;BR /&gt;&lt;BR /&gt;Sachin</description>
      <pubDate>Tue, 30 Oct 2001 17:00:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/2604152#M853152</guid>
      <dc:creator>Sachin Patel</dc:creator>
      <dc:date>2001-10-30T17:00:48Z</dc:date>
    </item>
    <item>
      <title>Re: scripting help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/2604153#M853153</link>
      <description>oops, didn't read that well.  The awk statment is for the last column, not the last line. &lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 30 Oct 2001 17:02:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/2604153#M853153</guid>
      <dc:creator>Craig Rants</dc:creator>
      <dc:date>2001-10-30T17:02:24Z</dc:date>
    </item>
    <item>
      <title>Re: scripting help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/2604154#M853154</link>
      <description>Yes, all these examples are great, but were missing one step.  I need to take the data from 30 of these files per month and tail them all, which im not exact on how to do this?&lt;BR /&gt;&lt;BR /&gt;I have 30 of the system1_1029, system1_1028,system1_1027 yada, yada, down to system1_1001...&lt;BR /&gt;&lt;BR /&gt;So if i tail all of them, how do i get all the average lines into one output file?&lt;BR /&gt;&lt;BR /&gt;Please advise?&lt;BR /&gt;&lt;BR /&gt;Vito</description>
      <pubDate>Tue, 30 Oct 2001 17:10:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/2604154#M853154</guid>
      <dc:creator>Vito Sarducci</dc:creator>
      <dc:date>2001-10-30T17:10:01Z</dc:date>
    </item>
    <item>
      <title>Re: scripting help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/2604155#M853155</link>
      <description>If you want to process on multiple files, then use "for"&lt;BR /&gt;&lt;BR /&gt;for hostfile in system1* ; do&lt;BR /&gt; last -1 $hostfile &amp;gt;&amp;gt;collect_file&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;This will extract the last line of each of the files and append onto collect_file&lt;BR /&gt;&lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Tue, 30 Oct 2001 17:29:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/2604155#M853155</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2001-10-30T17:29:02Z</dc:date>
    </item>
    <item>
      <title>Re: scripting help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/2604156#M853156</link>
      <description>for i in system1_10*&lt;BR /&gt;do&lt;BR /&gt;   tail -1 $i &lt;BR /&gt;done |awk '{T2+=$2} {T3+=$3} {T4+=$4} {T5+=$5} {print} END {printf"AVE: %f %f %f\n",T2/NR,T3/NR,T4/NR,T5/NR}' &amp;gt;&amp;gt; 10.sum&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Play with formatting etc. as you desire.&lt;BR /&gt;</description>
      <pubDate>Tue, 30 Oct 2001 17:31:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/2604156#M853156</guid>
      <dc:creator>Alan Riggs</dc:creator>
      <dc:date>2001-10-30T17:31:16Z</dc:date>
    </item>
  </channel>
</rss>

