<?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: Script Urgent !! in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/script-urgent/m-p/5006600#M425673</link>
    <description>&lt;!--!*#--&gt;cat file1 file2 | awk '{if (c[$1] == 0) {c[$1]=-$2; next;}&lt;BR /&gt;                c[$1]=c[$1] + $2} END {for(f in c) printf("%s %d\n",f,c[f])}' | sort&lt;BR /&gt;</description>
    <pubDate>Tue, 03 Oct 2006 15:11:32 GMT</pubDate>
    <dc:creator>Jonathan Fife</dc:creator>
    <dc:date>2006-10-03T15:11:32Z</dc:date>
    <item>
      <title>Script Urgent !!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-urgent/m-p/5006597#M425670</link>
      <description>Gentlemen [ oh ladies too ;) ]&lt;BR /&gt;&lt;BR /&gt;I have two files&lt;BR /&gt;&lt;BR /&gt;cat file1&lt;BR /&gt;&lt;BR /&gt;host1-80   10&lt;BR /&gt;host2-80   15&lt;BR /&gt;&lt;BR /&gt;cat file2&lt;BR /&gt;&lt;BR /&gt;host1-80   30&lt;BR /&gt;host2-80   20&lt;BR /&gt;&lt;BR /&gt;BAsically they are the number of hits to an apps server and the files are created on a daily basis. I want to print the diffrence of second column ( file2 - file1 ) &lt;BR /&gt;&lt;BR /&gt;i.e., &lt;BR /&gt;&lt;BR /&gt;cat result&lt;BR /&gt;&lt;BR /&gt;host1-80   20&lt;BR /&gt;host2-80   5&lt;BR /&gt;&lt;BR /&gt;Can anybody help with the simplest code. I can use Korn shell, perl, awk, sed .... anything.&lt;BR /&gt;&lt;BR /&gt;Thanks in advance,&lt;BR /&gt;&lt;BR /&gt;Kaps</description>
      <pubDate>Tue, 03 Oct 2006 14:36:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-urgent/m-p/5006597#M425670</guid>
      <dc:creator>KapilRaj</dc:creator>
      <dc:date>2006-10-03T14:36:11Z</dc:date>
    </item>
    <item>
      <title>Re: Script Urgent !!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-urgent/m-p/5006598#M425671</link>
      <description>Try this, did some perl:&lt;BR /&gt;&lt;BR /&gt;#!/usr/contrib/bin/perl -w&lt;BR /&gt;&lt;BR /&gt;my $file1 = "/tmp/foo1.txt";&lt;BR /&gt;my $file2 = "/tmp/foo2.txt";&lt;BR /&gt;&lt;BR /&gt;open FILE, "&amp;lt; ".$file1 || die "Can't open file: $@";&lt;BR /&gt;@file1 = &lt;FILE&gt;;&lt;BR /&gt;close (FILE);&lt;BR /&gt;&lt;BR /&gt;open FILE, "&amp;lt; ".$file2 || die "Can't open file: $@";&lt;BR /&gt;@file2 = &lt;FILE&gt;;&lt;BR /&gt;close (FILE);&lt;BR /&gt;&lt;BR /&gt;foreach my $line1 (@file1) {&lt;BR /&gt;        chomp($line1);&lt;BR /&gt;        my @array1 = split(/ /, $line1);&lt;BR /&gt;        foreach my $line2 (@file2) {&lt;BR /&gt;                chomp($line2);&lt;BR /&gt;                my @array2 = split(/ /, $line2);&lt;BR /&gt;                if ($array1[0] eq $array2[0]) {&lt;BR /&gt;                        print "Difference for ".$array2[0].": ".($array2[1] - $array1[1])."\n";&lt;BR /&gt;                }&lt;BR /&gt;        }&lt;BR /&gt;}&lt;BR /&gt;&lt;/FILE&gt;&lt;/FILE&gt;</description>
      <pubDate>Tue, 03 Oct 2006 15:05:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-urgent/m-p/5006598#M425671</guid>
      <dc:creator>Richard Fogle</dc:creator>
      <dc:date>2006-10-03T15:05:11Z</dc:date>
    </item>
    <item>
      <title>Re: Script Urgent !!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-urgent/m-p/5006599#M425672</link>
      <description>Hi, Kaps I assume you only have two hosts in each data file:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/ksh&lt;BR /&gt;&lt;BR /&gt;host1var1=`grep "host1-80" file1|cut -d" " -f2`&lt;BR /&gt;host2var1=`grep "host2-80" file1|cut -d" " -f2`&lt;BR /&gt;host1var2=`grep "host1-80" file2|cut -d" " -f2`&lt;BR /&gt;host2var2=`grep "host2-80" file2|cut -d" " -f2`&lt;BR /&gt;&lt;BR /&gt;host1rslt=$(($host1var2-$host1var1))&lt;BR /&gt;host2rslt=$(($host2var2-$host2var1))&lt;BR /&gt;&lt;BR /&gt;echo "host1-80 " $host1rslt &lt;BR /&gt;echo "host2-80 " $host2rslt&lt;BR /&gt;&lt;BR /&gt;exit&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Yang</description>
      <pubDate>Tue, 03 Oct 2006 15:06:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-urgent/m-p/5006599#M425672</guid>
      <dc:creator>Yang Qin_1</dc:creator>
      <dc:date>2006-10-03T15:06:21Z</dc:date>
    </item>
    <item>
      <title>Re: Script Urgent !!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-urgent/m-p/5006600#M425673</link>
      <description>&lt;!--!*#--&gt;cat file1 file2 | awk '{if (c[$1] == 0) {c[$1]=-$2; next;}&lt;BR /&gt;                c[$1]=c[$1] + $2} END {for(f in c) printf("%s %d\n",f,c[f])}' | sort&lt;BR /&gt;</description>
      <pubDate>Tue, 03 Oct 2006 15:11:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-urgent/m-p/5006600#M425673</guid>
      <dc:creator>Jonathan Fife</dc:creator>
      <dc:date>2006-10-03T15:11:32Z</dc:date>
    </item>
    <item>
      <title>Re: Script Urgent !!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-urgent/m-p/5006601#M425674</link>
      <description>#!/usr/bin/ksh&lt;BR /&gt;&lt;BR /&gt;SERVERS="host1-80 host2-80"&lt;BR /&gt;RESULT=0&lt;BR /&gt;&lt;BR /&gt;for i in $SERVERS&lt;BR /&gt;do&lt;BR /&gt;        RESULT=0&lt;BR /&gt;        HITFILE1=$(cat file1 | grep $i | awk '{print $2}')&lt;BR /&gt;        HITFILE2=$(cat file2 | grep $i | awk '{print $2}')&lt;BR /&gt;        if [ $HITFILE1 -gt $HITFILE2 ]&lt;BR /&gt;        then&lt;BR /&gt;                echo $HITFILE1 $HITFILE2&lt;BR /&gt;                RESULT=`echo $HITFILE1-$HITFILE2|bc`&lt;BR /&gt;        else&lt;BR /&gt;                echo $HITFILE2 $HITFILE1&lt;BR /&gt;                RESULT=`echo $HITFILE2-$HITFILE1|bc`&lt;BR /&gt;        fi&lt;BR /&gt;        echo $RESULT&lt;BR /&gt;done&lt;BR /&gt;</description>
      <pubDate>Tue, 03 Oct 2006 15:12:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-urgent/m-p/5006601#M425674</guid>
      <dc:creator>Jannik</dc:creator>
      <dc:date>2006-10-03T15:12:15Z</dc:date>
    </item>
    <item>
      <title>Re: Script Urgent !!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-urgent/m-p/5006602#M425675</link>
      <description>stupid expensive script, yet simple:&lt;BR /&gt;&lt;BR /&gt;#!/bin/sh&lt;BR /&gt;&lt;BR /&gt;cat file1 | while read host value1&lt;BR /&gt;do&lt;BR /&gt; value2=`grep $host file2|awk '{print $2}'`&lt;BR /&gt; echo $host `expr $value2 - $value1`&lt;BR /&gt;done&lt;BR /&gt;</description>
      <pubDate>Tue, 03 Oct 2006 15:16:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-urgent/m-p/5006602#M425675</guid>
      <dc:creator>Michal Toth</dc:creator>
      <dc:date>2006-10-03T15:16:22Z</dc:date>
    </item>
    <item>
      <title>Re: Script Urgent !!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-urgent/m-p/5006603#M425676</link>
      <description>#perl -ne '($h,$n)=split; if ($old=$o{$h}) {print "$h : ", $n - $old, "\n"} else {$o{$h}=$n}' file1.txt file2.txt&lt;BR /&gt;host1-80 : 20&lt;BR /&gt;host2-80 : 5&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;- read both files.&lt;BR /&gt;- split line into 'host name' and 'new count'&lt;BR /&gt;- if old count in array&lt;BR /&gt;--- then subtract and print&lt;BR /&gt;--- else stick new value into array.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;Hein.&lt;BR /&gt;</description>
      <pubDate>Tue, 03 Oct 2006 15:26:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-urgent/m-p/5006603#M425676</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2006-10-03T15:26:52Z</dc:date>
    </item>
    <item>
      <title>Re: Script Urgent !!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-urgent/m-p/5006604#M425677</link>
      <description>I think Jonathan Fife wins this one with the awk one-liner, I just wanted to use perl in mine.  Getting sick of nothing but shell utils.&lt;BR /&gt;</description>
      <pubDate>Tue, 03 Oct 2006 15:30:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-urgent/m-p/5006604#M425677</guid>
      <dc:creator>Richard Fogle</dc:creator>
      <dc:date>2006-10-03T15:30:53Z</dc:date>
    </item>
    <item>
      <title>Re: Script Urgent !!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-urgent/m-p/5006605#M425678</link>
      <description>I was going to post perl, too.  I agree, the awk one liner is impressive.</description>
      <pubDate>Tue, 03 Oct 2006 15:40:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-urgent/m-p/5006605#M425678</guid>
      <dc:creator>Sean Dale</dc:creator>
      <dc:date>2006-10-03T15:40:29Z</dc:date>
    </item>
    <item>
      <title>Re: Script Urgent !!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-urgent/m-p/5006606#M425679</link>
      <description>Michael , I never thought of it. It was so simple.&lt;BR /&gt;Richard Fogle , Thanks It does work.&lt;BR /&gt;Yang, Thanks it works as long as the file has just 2 lines.&lt;BR /&gt;Jonathan Fife , I wish I could give you 20 points !! Fantastic !! Wow ! I wish I could script like that !&lt;BR /&gt;Jannik , Thanks .. it is again hard coded .. yet I appreciate your time spent on my request.&lt;BR /&gt;Hein van den Heuvel, Wow ! Perl is always perl ! Wonderfull !&lt;BR /&gt;&lt;BR /&gt;Thank you very much guys ...&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;Kaps</description>
      <pubDate>Tue, 03 Oct 2006 16:00:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-urgent/m-p/5006606#M425679</guid>
      <dc:creator>KapilRaj</dc:creator>
      <dc:date>2006-10-03T16:00:48Z</dc:date>
    </item>
    <item>
      <title>Re: Script Urgent !!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-urgent/m-p/5006607#M425680</link>
      <description>Thanks to all once again. Thanks for your time. Points are awarded.</description>
      <pubDate>Tue, 03 Oct 2006 16:03:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-urgent/m-p/5006607#M425680</guid>
      <dc:creator>KapilRaj</dc:creator>
      <dc:date>2006-10-03T16:03:17Z</dc:date>
    </item>
  </channel>
</rss>

