<?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 awk program help in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/awk-program-help/m-p/4984977#M99963</link>
    <description>Hello,&lt;BR /&gt;&lt;BR /&gt;I have a file with multiple entries of start and finish times:&lt;BR /&gt;&lt;BR /&gt;R1 Stock Started Thu 28 Jul 08:52:00 2005&lt;BR /&gt;R1 Stock Finished Thu 28 Jul 08:52:15 2005&lt;BR /&gt;&lt;BR /&gt;I would like to use awk to calculate the amount of time it took for R1 to complete.&lt;BR /&gt;&lt;BR /&gt;A million Thank U's</description>
    <pubDate>Tue, 13 Jun 2006 04:01:53 GMT</pubDate>
    <dc:creator>lawrenzo_1</dc:creator>
    <dc:date>2006-06-13T04:01:53Z</dc:date>
    <item>
      <title>awk program help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-program-help/m-p/4984977#M99963</link>
      <description>Hello,&lt;BR /&gt;&lt;BR /&gt;I have a file with multiple entries of start and finish times:&lt;BR /&gt;&lt;BR /&gt;R1 Stock Started Thu 28 Jul 08:52:00 2005&lt;BR /&gt;R1 Stock Finished Thu 28 Jul 08:52:15 2005&lt;BR /&gt;&lt;BR /&gt;I would like to use awk to calculate the amount of time it took for R1 to complete.&lt;BR /&gt;&lt;BR /&gt;A million Thank U's</description>
      <pubDate>Tue, 13 Jun 2006 04:01:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-program-help/m-p/4984977#M99963</guid>
      <dc:creator>lawrenzo_1</dc:creator>
      <dc:date>2006-06-13T04:01:53Z</dc:date>
    </item>
    <item>
      <title>Re: awk program help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-program-help/m-p/4984978#M99964</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Are these entries consecutive entries or can be anywhere.&lt;BR /&gt;e.g. are these entries of type&lt;BR /&gt;R1 Stock Started time1&lt;BR /&gt;R1 Stock Finished time2&lt;BR /&gt;R1 Stock Started time3&lt;BR /&gt;R1 Stock Finished time4&lt;BR /&gt;R1 Stock Started time5&lt;BR /&gt;R1 Stock Finished time6&lt;BR /&gt;&lt;BR /&gt;OR can be&lt;BR /&gt;&lt;BR /&gt;R1 Stock Started time1&lt;BR /&gt;R1 Stock Started time3&lt;BR /&gt;R1 Stock Finished time2&lt;BR /&gt;R1 Stock Finished time4&lt;BR /&gt;R1 Stock Started time5&lt;BR /&gt;R1 Stock Finished time6&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Ninad</description>
      <pubDate>Tue, 13 Jun 2006 04:17:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-program-help/m-p/4984978#M99964</guid>
      <dc:creator>Ninad_1</dc:creator>
      <dc:date>2006-06-13T04:17:33Z</dc:date>
    </item>
    <item>
      <title>Re: awk program help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-program-help/m-p/4984979#M99965</link>
      <description>244 entries of stop and start al stop and start on the same date&lt;BR /&gt;&lt;BR /&gt;Thanks man</description>
      <pubDate>Tue, 13 Jun 2006 04:25:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-program-help/m-p/4984979#M99965</guid>
      <dc:creator>lawrenzo_1</dc:creator>
      <dc:date>2006-06-13T04:25:18Z</dc:date>
    </item>
    <item>
      <title>Re: awk program help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-program-help/m-p/4984980#M99966</link>
      <description>What I wanted to know is that will the start entry be followed by the corresponding stop entry immediately on the next line ? &lt;BR /&gt;OR&lt;BR /&gt;There can be start entries mixed with stop entries as mentioned in my examples above. So the stop entry for instance 1 does not necessarily follow on the next immediate line of the start for instance 1 , and it may follow some where down the line after say start entries for instance 2 , 3 etc.&lt;BR /&gt;&lt;BR /&gt;Please can you clarify this .&lt;BR /&gt;&lt;BR /&gt;If it is the 1st case then following should do (replace 1.dat by your filename)&lt;BR /&gt;&lt;BR /&gt;awk '/Started/,/Finished/  {&lt;BR /&gt;{if(match($3,"Started") == 1) starttime=$7};getline;&lt;BR /&gt;{if(match($3,"Finished") == 1) stoptime=$7}}&lt;BR /&gt;{print starttime,stoptime}' 1.dat | while read starttime stoptime&lt;BR /&gt;do&lt;BR /&gt;time1=$(echo $starttime | tr -s ":" " " | awk '{print (($1*3600)+($2*60)+$3)}')&lt;BR /&gt;time2=$(echo $stoptime | tr -s ":" " " | awk '{print (($1*3600)+($2*60)+$3)}')&lt;BR /&gt;timeelapsed=$(echo "($time2 - $time1)" | bc)&lt;BR /&gt;echo "Time elapsed = $timeelapsed seconds"&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Ninad</description>
      <pubDate>Tue, 13 Jun 2006 06:10:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-program-help/m-p/4984980#M99966</guid>
      <dc:creator>Ninad_1</dc:creator>
      <dc:date>2006-06-13T06:10:08Z</dc:date>
    </item>
    <item>
      <title>Re: awk program help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-program-help/m-p/4984981#M99967</link>
      <description>ok sorry didnt understand your question.&lt;BR /&gt;&lt;BR /&gt;Thanks for a solution i am pretty sure I will be able to work something out.&lt;BR /&gt;&lt;BR /&gt;I have created the file with the start and stop entries and it goes &lt;BR /&gt;&lt;BR /&gt;R1 Stock Started Thu 28 Jul 08:52:00 2005&lt;BR /&gt;R1 Stock Finished Thu 28 Jul 08:52:15 2005&lt;BR /&gt;R1 Stock Started Thu 29 Jul 08:52:00 2005&lt;BR /&gt;R1 Stock Finished Thu 29 Jul 08:52:27 2005&lt;BR /&gt;R1 Stock Started Thu 30 Jul 08:52:00 2005&lt;BR /&gt;R1 Stock Finished Thu 30 Jul 08:52:01 2005&lt;BR /&gt;&lt;BR /&gt;I'll let you know my results.&lt;BR /&gt;&lt;BR /&gt;TY&lt;BR /&gt;</description>
      <pubDate>Tue, 13 Jun 2006 07:32:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-program-help/m-p/4984981#M99967</guid>
      <dc:creator>lawrenzo_1</dc:creator>
      <dc:date>2006-06-13T07:32:48Z</dc:date>
    </item>
    <item>
      <title>Re: awk program help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-program-help/m-p/4984982#M99968</link>
      <description>Lawrenzo,&lt;BR /&gt;&lt;BR /&gt;As long as the 'start-finished-start-finished' pattern is upheld, the starttime is always 08:52, and the duration is always &amp;lt;8 minutes, you can use this simple one-liner:&lt;BR /&gt;&lt;BR /&gt;awk '/Finished/{print substr($7,5,1)-2 substr($7,6,3)}' &lt;FILE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;PCS&lt;/FILE&gt;</description>
      <pubDate>Tue, 13 Jun 2006 08:26:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-program-help/m-p/4984982#M99968</guid>
      <dc:creator>spex</dc:creator>
      <dc:date>2006-06-13T08:26:58Z</dc:date>
    </item>
    <item>
      <title>Re: awk program help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-program-help/m-p/4984983#M99969</link>
      <description>awk '/Started/,/Finished/ {&lt;BR /&gt;{if(match($3,"Started") == 1) starttime=$7};getline;&lt;BR /&gt;{if(match($3,"Finished") == 1) stoptime=$7}}&lt;BR /&gt;{print starttime,stoptime}' 1.dat | while read starttime stoptime&lt;BR /&gt;do&lt;BR /&gt;time1=$(echo $starttime | tr -s ":" " " | awk '{print (($1*3600)+($2*60)+$3)}')&lt;BR /&gt;time2=$(echo $stoptime | tr -s ":" " " | awk '{print (($1*3600)+($2*60)+$3)}')&lt;BR /&gt;timeelapsed=$(echo "($time2 - $time1)" | bc)&lt;BR /&gt;echo "Time elapsed = $timeelapsed seconds"&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;worked fine for me&lt;BR /&gt;&lt;BR /&gt;Thanks chaps</description>
      <pubDate>Tue, 13 Jun 2006 10:37:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-program-help/m-p/4984983#M99969</guid>
      <dc:creator>lawrenzo_1</dc:creator>
      <dc:date>2006-06-13T10:37:59Z</dc:date>
    </item>
  </channel>
</rss>

