<?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: Need help in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/need-help/m-p/4968813#M101770</link>
    <description>Hmmm, Muthu... I fail to see how you can solve the problem described with the simple array comparison you suggest. It seems clear to me that any solution needs to focus on the first, 'key' field.&lt;BR /&gt;How else can one decided whether a a new record appeared in the same place where an old record was deleted?&lt;BR /&gt;&lt;BR /&gt;Anyway...&lt;BR /&gt;&lt;BR /&gt;For a large file, it probably needs to be pre-sorted and two two files read simultaneously comparing key values to keep then in sync.&lt;BR /&gt;I presented one example of this is in:&lt;BR /&gt;&lt;A href="http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=999120" target="_blank"&gt;http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=999120&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;For small files you can just 'slurp' them into a perl associative array, and report based on keys.&lt;BR /&gt;&lt;BR /&gt;Here is an example that only compares the first non-field. It is easily adapted to compare other fields, or just everything except the key.&lt;BR /&gt;&lt;BR /&gt;------ compare.pl ---------&lt;BR /&gt;$file = shift;&lt;BR /&gt;open (FILE, "&amp;lt;$file") or die "Failed to open first file: $file.";&lt;BR /&gt;while (&lt;FILE&gt;) {&lt;BR /&gt;chomp;&lt;BR /&gt;($key,$flag,$num) = split (/\|/, $_);&lt;BR /&gt;print "$. $key,$flag,$num\n";&lt;BR /&gt;$f1_flag{$key} = $flag;&lt;BR /&gt;$f1_num{$key} = $num;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;$file = shift;&lt;BR /&gt;open (FILE, "&amp;lt;$file") or die "Failed to open second file: $file.";&lt;BR /&gt;while (&lt;FILE&gt;) {&lt;BR /&gt;chomp;&lt;BR /&gt;($key,$flag,$num) = split (/\|/, $_);&lt;BR /&gt;print "$. $key,$flag,$num\n";&lt;BR /&gt;$f2_flag{$key} = $flag;&lt;BR /&gt;$f2_num{$key} = $num;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;for $key (sort keys %f2_flag) {&lt;BR /&gt;  $change = "=";&lt;BR /&gt;  if (defined $f1_flag{$key}) {&lt;BR /&gt;      $change = "c" if ($f1_flag{$key} ne $f2_flag{$key});&lt;BR /&gt;      delete $f1_flag{$key};&lt;BR /&gt;  } else {&lt;BR /&gt;      $change = "a";&lt;BR /&gt;  }&lt;BR /&gt;  print "$key|$f2_flag{$key}|$f2_num{$key}| $change\n"&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;for $key (sort keys %f1_flag) {&lt;BR /&gt;  print "$key|$f1_flag{$key}|$f1_num{$key}| d\n"&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;---- usage example ----&lt;BR /&gt;&lt;BR /&gt;C:\Temp&amp;gt;type file1.tmp&lt;BR /&gt;p1|y|500&lt;BR /&gt;p2|n|500&lt;BR /&gt;p5|y|500&lt;BR /&gt;C:\Temp&amp;gt;type file2.tmp&lt;BR /&gt;p1|n|500&lt;BR /&gt;p3|y|501&lt;BR /&gt;p5|y|500&lt;BR /&gt;C:\Temp&amp;gt;perl tmp.pl file1.tmp file2.tmp&lt;BR /&gt;p1|n|500 | c&lt;BR /&gt;p3|y|501 | a&lt;BR /&gt;p5|y|500 | =&lt;BR /&gt;p2|n|500 | d&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;if this input is treated as 'key' and everything else then it simplyfies some&lt;BR /&gt;&lt;BR /&gt;------- compare_2.pl ----------&lt;BR /&gt;&lt;BR /&gt;$file = shift;&lt;BR /&gt;open (FILE, "&amp;lt;$file") or die "Failed to open first file: $file.";&lt;BR /&gt;while (&lt;FILE&gt;) {&lt;BR /&gt;chomp;&lt;BR /&gt;$f1{$`} = $' if /\|/;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;$file = shift;&lt;BR /&gt;open (FILE, "&amp;lt;$file") or die "Failed to open second file: $file.";&lt;BR /&gt;while (&lt;FILE&gt;) {&lt;BR /&gt;chomp;&lt;BR /&gt;$f2{$`} = $' if /\|/;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;for $key (sort keys %f2) {&lt;BR /&gt;  $change = "=";&lt;BR /&gt;  if (defined $f1{$key}) {&lt;BR /&gt;      $change = "c" if ($f1{$key} ne $f2{$key});&lt;BR /&gt;      delete $f1{$key};&lt;BR /&gt;  } else {&lt;BR /&gt;      $change = "a";&lt;BR /&gt;  }&lt;BR /&gt;  print "$key|$f2{$key}| $change\n"&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;for $key (sort keys %f1) {&lt;BR /&gt;  print "$key|$f1{$key}| d\n"&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;/FILE&gt;&lt;/FILE&gt;&lt;/FILE&gt;&lt;/FILE&gt;</description>
    <pubDate>Fri, 24 Mar 2006 12:08:17 GMT</pubDate>
    <dc:creator>Hein van den Heuvel</dc:creator>
    <dc:date>2006-03-24T12:08:17Z</dc:date>
    <item>
      <title>Need help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/need-help/m-p/4968803#M101760</link>
      <description>I have a problem with comparing the columns of 2 files and write a status like add, modified or delete in the outfile along with the records of these 2 file. &lt;BR /&gt;For ex :&lt;BR /&gt;&lt;BR /&gt;consider my 1st file has say &lt;BR /&gt;file1&lt;BR /&gt;==========     &lt;BR /&gt;p1|y|500            &lt;BR /&gt;p2|n|500              &lt;BR /&gt;&lt;BR /&gt;file2&lt;BR /&gt;======&lt;BR /&gt;p1| n| 500&lt;BR /&gt;p3 | y|501&lt;BR /&gt;&lt;BR /&gt;now my output file should be like this &lt;BR /&gt;&lt;BR /&gt;output file &lt;BR /&gt;=========&lt;BR /&gt;p1 | n| 500 |c   b'cas it has been changed   from y to n in the 1st file&lt;BR /&gt;p2| n |500  | d   b'cas p2 is deleted in the 2nd file&lt;BR /&gt;p3 | y| 501 | a    b'cas p3 is added in the 2nd file &lt;BR /&gt;&lt;BR /&gt;could you please help me out. I want either a shell script or a awk command .&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 22 Mar 2006 04:19:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/need-help/m-p/4968803#M101760</guid>
      <dc:creator>suchitra</dc:creator>
      <dc:date>2006-03-22T04:19:04Z</dc:date>
    </item>
    <item>
      <title>Re: Need help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/need-help/m-p/4968804#M101761</link>
      <description>Use this:&lt;BR /&gt;&lt;BR /&gt;awk -F"\|" '{ var=$0;var1=$1;var2=$2;var3=$3;getline &amp;lt; "file2";split($0,a,"|"); if ( a[1] == var1 ) { if ( a[2] != var2 ) { print var"## c bcas "var2" is changed to "a[2];} if ( a[3] != var3 ) { print var"## c bcas "var3" is changed in 2nd file";} }&lt;BR /&gt;else { print var"## d bcas "var1" is deleted in 2nd file";print $0" ## a bcas "a[1]" is deleted in 2nd file";}}' file1&lt;BR /&gt;&lt;BR /&gt;--&lt;BR /&gt;Muthu</description>
      <pubDate>Wed, 22 Mar 2006 04:46:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/need-help/m-p/4968804#M101761</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2006-03-22T04:46:36Z</dc:date>
    </item>
    <item>
      <title>Re: Need help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/need-help/m-p/4968805#M101762</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;Look at the comm command&lt;BR /&gt;&lt;BR /&gt;comm - select or reject lines common to two sorted files&lt;BR /&gt;&lt;BR /&gt;And &lt;A href="http://www.shelldorado.com" target="_blank"&gt;www.shelldorado.com&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;            Steve Steel</description>
      <pubDate>Wed, 22 Mar 2006 04:47:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/need-help/m-p/4968805#M101762</guid>
      <dc:creator>Steve Steel</dc:creator>
      <dc:date>2006-03-22T04:47:35Z</dc:date>
    </item>
    <item>
      <title>Re: Need help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/need-help/m-p/4968806#M101763</link>
      <description>Suchitra,&lt;BR /&gt;my ititial solution:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;echo "Changed"&lt;BR /&gt;echo "`join -j 1 -t '|' -o 1.1 2.2 1.3 file1 file2`|c" &lt;BR /&gt;echo "Deleted" &lt;BR /&gt;cut -f1 -d '|' file1 &amp;gt; file1.bck&lt;BR /&gt;cut -f1 -d '|' file2 &amp;gt; file2.bck&lt;BR /&gt;grep `comm -23 file1.bck file2.bck` file1 &amp;gt; file1.res&lt;BR /&gt;sed "1,$ s/$/|d/" file1.res&lt;BR /&gt;rm file1.res&lt;BR /&gt;echo "Added"&lt;BR /&gt;grep `comm -13 file1.bck file2.bck` file2 &amp;gt; file2.res&lt;BR /&gt;sed "1,$ s/$/|a/" file2.res&lt;BR /&gt;rm file2.res&lt;BR /&gt;rm file1.bck&lt;BR /&gt;rm file2.bck&lt;BR /&gt;</description>
      <pubDate>Wed, 22 Mar 2006 04:56:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/need-help/m-p/4968806#M101763</guid>
      <dc:creator>Peter Godron</dc:creator>
      <dc:date>2006-03-22T04:56:39Z</dc:date>
    </item>
    <item>
      <title>Re: Need help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/need-help/m-p/4968807#M101764</link>
      <description>Muthukumar,&lt;BR /&gt;very smooth script!&lt;BR /&gt;The first "print var" could be replaced by:&lt;BR /&gt;print a[1]"|"a[2]"|"a[3]&lt;BR /&gt;to pick up the file2 values, rather than file1.</description>
      <pubDate>Wed, 22 Mar 2006 05:10:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/need-help/m-p/4968807#M101764</guid>
      <dc:creator>Peter Godron</dc:creator>
      <dc:date>2006-03-22T05:10:43Z</dc:date>
    </item>
    <item>
      <title>Re: Need help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/need-help/m-p/4968808#M101765</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;     I have attached a script that uses "comm" command for your situation.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Senthil Kumar .A</description>
      <pubDate>Wed, 22 Mar 2006 05:16:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/need-help/m-p/4968808#M101765</guid>
      <dc:creator>Senthil Kumar .A_1</dc:creator>
      <dc:date>2006-03-22T05:16:55Z</dc:date>
    </item>
    <item>
      <title>Re: Need help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/need-help/m-p/4968809#M101766</link>
      <description>Peter,&lt;BR /&gt;&lt;BR /&gt;To avoid to print a whole line as a[1]"|"a[2]"|"a[3], I have stored in a separate variable. It is help ful to simply script ;)&lt;BR /&gt;&lt;BR /&gt;--&lt;BR /&gt;Muthu</description>
      <pubDate>Wed, 22 Mar 2006 05:21:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/need-help/m-p/4968809#M101766</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2006-03-22T05:21:23Z</dc:date>
    </item>
    <item>
      <title>Re: Need help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/need-help/m-p/4968810#M101767</link>
      <description>Suchitra,&lt;BR /&gt;something else to keep in mind is that any script using comm would only work on sorted files.&lt;BR /&gt;&lt;BR /&gt;Also, are there any duplicate keys like:&lt;BR /&gt;p1|y|500&lt;BR /&gt;p1|n|300&lt;BR /&gt;.&lt;BR /&gt;.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 22 Mar 2006 05:29:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/need-help/m-p/4968810#M101767</guid>
      <dc:creator>Peter Godron</dc:creator>
      <dc:date>2006-03-22T05:29:10Z</dc:date>
    </item>
    <item>
      <title>Re: Need help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/need-help/m-p/4968811#M101768</link>
      <description>Using perl:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;&lt;BR /&gt;open FD1,"file1" || die "Open Error: $!";&lt;BR /&gt;open FD2,"file2" || die "Open Error: $!";&lt;BR /&gt;&lt;BR /&gt;@arr1=&lt;FD1&gt;;&lt;BR /&gt;@arr2=&lt;FD2&gt;;&lt;BR /&gt;&lt;BR /&gt;for ($i=0;$i&amp;lt;@arr1;$i++)&lt;BR /&gt;{&lt;BR /&gt;  @pat1=split (/\|/,$arr1[$i]);&lt;BR /&gt;  @pat2=split (/\|/,$arr2[$i]);&lt;BR /&gt;  &lt;BR /&gt;  $arr1[$i]=~chomp($arr1[$i]);&lt;BR /&gt;  $arr2[$i]=~chomp($arr2[$i]);&lt;BR /&gt;  &lt;BR /&gt;  if ( $pat1[0] eq $pat2[0] )&lt;BR /&gt;  {&lt;BR /&gt;    if ( $pat1[1] ne $pat2[1] )&lt;BR /&gt;    {&lt;BR /&gt;       &lt;BR /&gt;      print "$arr1[$i] | c b'cas it has been changed from $pat1[1] to $pat2[1] in field 2 in 2nd file\n";&lt;BR /&gt;    }  &lt;BR /&gt;    if ( $pat1[2] ne $pat2[2] )&lt;BR /&gt;    {&lt;BR /&gt;      print "$arr1[$i] | c b'cas it has been changed from $pat1[2] to $pat2[2] in field 3 in 2nd file\n";&lt;BR /&gt;    }  &lt;BR /&gt;&lt;BR /&gt;  }&lt;BR /&gt;  else&lt;BR /&gt;  {&lt;BR /&gt;    print "$arr1[$i] | d b'cas $pat1[0] is deleted in 2nd file\n";&lt;BR /&gt;    print "$arr2[$i] | a b'cas $pat1[0] is added in 2nd file\n";&lt;BR /&gt;  }&lt;BR /&gt;    &lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;# END&lt;BR /&gt;&lt;BR /&gt;--&lt;BR /&gt;Muthu&lt;/FD2&gt;&lt;/FD1&gt;</description>
      <pubDate>Wed, 22 Mar 2006 05:46:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/need-help/m-p/4968811#M101768</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2006-03-22T05:46:24Z</dc:date>
    </item>
    <item>
      <title>Re: Need help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/need-help/m-p/4968812#M101769</link>
      <description>Suchitra,&lt;BR /&gt;do these answers solve your problem?&lt;BR /&gt;Can you please have a look at:&lt;BR /&gt;&lt;A href="http://forums1.itrc.hp.com/service/forums/helptips.do?#28" target="_blank"&gt;http://forums1.itrc.hp.com/service/forums/helptips.do?#28&lt;/A&gt;&lt;BR /&gt;and then update the record.</description>
      <pubDate>Fri, 24 Mar 2006 10:29:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/need-help/m-p/4968812#M101769</guid>
      <dc:creator>Peter Godron</dc:creator>
      <dc:date>2006-03-24T10:29:37Z</dc:date>
    </item>
    <item>
      <title>Re: Need help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/need-help/m-p/4968813#M101770</link>
      <description>Hmmm, Muthu... I fail to see how you can solve the problem described with the simple array comparison you suggest. It seems clear to me that any solution needs to focus on the first, 'key' field.&lt;BR /&gt;How else can one decided whether a a new record appeared in the same place where an old record was deleted?&lt;BR /&gt;&lt;BR /&gt;Anyway...&lt;BR /&gt;&lt;BR /&gt;For a large file, it probably needs to be pre-sorted and two two files read simultaneously comparing key values to keep then in sync.&lt;BR /&gt;I presented one example of this is in:&lt;BR /&gt;&lt;A href="http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=999120" target="_blank"&gt;http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=999120&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;For small files you can just 'slurp' them into a perl associative array, and report based on keys.&lt;BR /&gt;&lt;BR /&gt;Here is an example that only compares the first non-field. It is easily adapted to compare other fields, or just everything except the key.&lt;BR /&gt;&lt;BR /&gt;------ compare.pl ---------&lt;BR /&gt;$file = shift;&lt;BR /&gt;open (FILE, "&amp;lt;$file") or die "Failed to open first file: $file.";&lt;BR /&gt;while (&lt;FILE&gt;) {&lt;BR /&gt;chomp;&lt;BR /&gt;($key,$flag,$num) = split (/\|/, $_);&lt;BR /&gt;print "$. $key,$flag,$num\n";&lt;BR /&gt;$f1_flag{$key} = $flag;&lt;BR /&gt;$f1_num{$key} = $num;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;$file = shift;&lt;BR /&gt;open (FILE, "&amp;lt;$file") or die "Failed to open second file: $file.";&lt;BR /&gt;while (&lt;FILE&gt;) {&lt;BR /&gt;chomp;&lt;BR /&gt;($key,$flag,$num) = split (/\|/, $_);&lt;BR /&gt;print "$. $key,$flag,$num\n";&lt;BR /&gt;$f2_flag{$key} = $flag;&lt;BR /&gt;$f2_num{$key} = $num;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;for $key (sort keys %f2_flag) {&lt;BR /&gt;  $change = "=";&lt;BR /&gt;  if (defined $f1_flag{$key}) {&lt;BR /&gt;      $change = "c" if ($f1_flag{$key} ne $f2_flag{$key});&lt;BR /&gt;      delete $f1_flag{$key};&lt;BR /&gt;  } else {&lt;BR /&gt;      $change = "a";&lt;BR /&gt;  }&lt;BR /&gt;  print "$key|$f2_flag{$key}|$f2_num{$key}| $change\n"&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;for $key (sort keys %f1_flag) {&lt;BR /&gt;  print "$key|$f1_flag{$key}|$f1_num{$key}| d\n"&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;---- usage example ----&lt;BR /&gt;&lt;BR /&gt;C:\Temp&amp;gt;type file1.tmp&lt;BR /&gt;p1|y|500&lt;BR /&gt;p2|n|500&lt;BR /&gt;p5|y|500&lt;BR /&gt;C:\Temp&amp;gt;type file2.tmp&lt;BR /&gt;p1|n|500&lt;BR /&gt;p3|y|501&lt;BR /&gt;p5|y|500&lt;BR /&gt;C:\Temp&amp;gt;perl tmp.pl file1.tmp file2.tmp&lt;BR /&gt;p1|n|500 | c&lt;BR /&gt;p3|y|501 | a&lt;BR /&gt;p5|y|500 | =&lt;BR /&gt;p2|n|500 | d&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;if this input is treated as 'key' and everything else then it simplyfies some&lt;BR /&gt;&lt;BR /&gt;------- compare_2.pl ----------&lt;BR /&gt;&lt;BR /&gt;$file = shift;&lt;BR /&gt;open (FILE, "&amp;lt;$file") or die "Failed to open first file: $file.";&lt;BR /&gt;while (&lt;FILE&gt;) {&lt;BR /&gt;chomp;&lt;BR /&gt;$f1{$`} = $' if /\|/;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;$file = shift;&lt;BR /&gt;open (FILE, "&amp;lt;$file") or die "Failed to open second file: $file.";&lt;BR /&gt;while (&lt;FILE&gt;) {&lt;BR /&gt;chomp;&lt;BR /&gt;$f2{$`} = $' if /\|/;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;for $key (sort keys %f2) {&lt;BR /&gt;  $change = "=";&lt;BR /&gt;  if (defined $f1{$key}) {&lt;BR /&gt;      $change = "c" if ($f1{$key} ne $f2{$key});&lt;BR /&gt;      delete $f1{$key};&lt;BR /&gt;  } else {&lt;BR /&gt;      $change = "a";&lt;BR /&gt;  }&lt;BR /&gt;  print "$key|$f2{$key}| $change\n"&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;for $key (sort keys %f1) {&lt;BR /&gt;  print "$key|$f1{$key}| d\n"&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;/FILE&gt;&lt;/FILE&gt;&lt;/FILE&gt;&lt;/FILE&gt;</description>
      <pubDate>Fri, 24 Mar 2006 12:08:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/need-help/m-p/4968813#M101770</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2006-03-24T12:08:17Z</dc:date>
    </item>
    <item>
      <title>Re: Need help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/need-help/m-p/4968814#M101771</link>
      <description>Mind you, Muthu's script may be great IF the data follows strict patterns. But I do not think it works as requested. For example with a single deleted line:&lt;BR /&gt;&lt;BR /&gt;C:\Temp&amp;gt;type file1.tmp&lt;BR /&gt;p1|y|500&lt;BR /&gt;p2|n|500&lt;BR /&gt;p3|y|500&lt;BR /&gt;p4|y|500&lt;BR /&gt;p5|y|500&lt;BR /&gt;C:\Temp&amp;gt;type file2.tmp&lt;BR /&gt;p1|n|500&lt;BR /&gt;p3|y|500&lt;BR /&gt;p4|y|500&lt;BR /&gt;p5|y|500&lt;BR /&gt;C:\Temp&amp;gt;perl test.pl&lt;BR /&gt;p2|n|500  | d b'cas p2 is deleted in 2nd file&lt;BR /&gt;p3|y|500 | a b'cas p2 is added in 2nd file&lt;BR /&gt;p3|y|500 | d b'cas p3 is deleted in 2nd file&lt;BR /&gt;p4|y|500 | a b'cas p3 is added in 2nd file&lt;BR /&gt;p4|y|500 | d b'cas p4 is deleted in 2nd file&lt;BR /&gt;p5|y|500 | a b'cas p4 is added in 2nd file&lt;BR /&gt;p5|y|500 | d b'cas p5 is deleted in 2nd file&lt;BR /&gt; | a b'cas p5 is added in 2nd file&lt;BR /&gt;&lt;BR /&gt;Using the script I suggest:&lt;BR /&gt;&lt;BR /&gt;p1|n|500 | c&lt;BR /&gt;p3|y|500 | =&lt;BR /&gt;p4|y|500 | =&lt;BR /&gt;p5|y|500 | =&lt;BR /&gt;p2|n|500 | d&lt;BR /&gt;&lt;BR /&gt;Of course my method will fail if the order is critical, and not this column 1 value.&lt;BR /&gt;&lt;BR /&gt;If the "=" lines are not desirable, then change the code to make the print conditional:&lt;BR /&gt;print "$key|$f2{$key}| $change\n" unless $change eq "=";&lt;BR /&gt;&lt;BR /&gt;or re-arrange the core look some. For example:&lt;BR /&gt;&lt;BR /&gt;for $key (sort keys %f2) {&lt;BR /&gt;$change = "c";&lt;BR /&gt;if ($x = $f1{$key}) {&lt;BR /&gt;   delete $f1{$key};&lt;BR /&gt;   next if ($x eq $f2{$key});&lt;BR /&gt;   } else {&lt;BR /&gt;   $change = "a";&lt;BR /&gt;}&lt;BR /&gt;print "$key|$f2{$key}| $change\n"&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Result for last input example:&lt;BR /&gt;&lt;BR /&gt;C:\Temp&amp;gt;perl compare.pl file1.tmp file2.tmp&lt;BR /&gt;p1|n|500 | c&lt;BR /&gt;p2|n|500 | d&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Ok, lunch break over, back to real work...&lt;BR /&gt;:-)&lt;BR /&gt;&lt;BR /&gt;Hein.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 24 Mar 2006 12:33:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/need-help/m-p/4968814#M101771</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2006-03-24T12:33:45Z</dc:date>
    </item>
    <item>
      <title>Re: Need help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/need-help/m-p/4968815#M101772</link>
      <description>Hi Suchitra,&lt;BR /&gt;&lt;BR /&gt;I'ave pasted a shell script below that satisfies the requirements for parsing and filtering input files according to your criteria:&lt;BR /&gt;&lt;BR /&gt;========================myparser.sh========================&lt;BR /&gt;#!/bin/sh&lt;BR /&gt;&lt;BR /&gt;set -a&lt;BR /&gt;&lt;BR /&gt;InFile1=f1&lt;BR /&gt;InFile2=f2&lt;BR /&gt;#&lt;BR /&gt;SortFile1=f1s&lt;BR /&gt;SortFile2=f2s&lt;BR /&gt;#&lt;BR /&gt;OutFile=outfile&lt;BR /&gt;&lt;BR /&gt;# Zero out the outputfile &lt;BR /&gt;# before input processing&lt;BR /&gt;cat /dev/null &amp;gt; $OutFile&lt;BR /&gt;&lt;BR /&gt;# Sort both file 1 and 2 on the first field&lt;BR /&gt;# using the vertical bar as field separator&lt;BR /&gt;sort -t"|" -k1 $InFile1 &amp;gt; $SortFile1&lt;BR /&gt;sort -t"|" -k1 $InFile2 &amp;gt; $SortFile2&lt;BR /&gt;&lt;BR /&gt;# Filter out lines common to both files&lt;BR /&gt;# and print out those that have changed&lt;BR /&gt;join -t"|" $SortFile1 $SortFile2 | awk -F"|" '&lt;BR /&gt;BEGIN {OFS="|"}&lt;BR /&gt;{if($2!=$4)print $1,$4,$NF,"c b'\''cas "$1" changed from "$2" to "$4" in 2nd file"}' &amp;gt;&amp;gt;$OutFile&lt;BR /&gt;&lt;BR /&gt;# Print out all the unmatched lines in&lt;BR /&gt;# sorted file 1 and flag them as deleted&lt;BR /&gt;join -t"|" -v1 $SortFile1 $SortFile2 | awk -F"|" '&lt;BR /&gt;BEGIN{OFS="|"} {print $0,"d b'\''cas "$1" is deleted in 2nd file"}' &amp;gt;&amp;gt;$OutFile&lt;BR /&gt;&lt;BR /&gt;# Print out all the unmatched lines in&lt;BR /&gt;# sorted file 2 and flag them as added&lt;BR /&gt;join -t"|" -v2 $SortFile1 $SortFile2 | awk -F"|" '&lt;BR /&gt;BEGIN{OFS="|"} {print $0,"a b'\''cas "$1" is added in 2nd file"}' &amp;gt;&amp;gt;$OutFile&lt;BR /&gt;===========================================================&lt;BR /&gt;&lt;BR /&gt;Copy the code into a file name of your choice, customize the environment (InFile, SortFile etc.) to your system, make it executable and run it at the command line.&lt;BR /&gt;&lt;BR /&gt;hope it helps!</description>
      <pubDate>Fri, 24 Mar 2006 19:56:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/need-help/m-p/4968815#M101772</guid>
      <dc:creator>Sandman!</dc:creator>
      <dc:date>2006-03-24T19:56:59Z</dc:date>
    </item>
    <item>
      <title>Re: Need help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/need-help/m-p/4968816#M101773</link>
      <description>Matter of fact the code might be easier to understand (as well as copy 'n paste) if attached instead of pasted...so click on the attachment for the shell script.&lt;BR /&gt;&lt;BR /&gt;cheers!</description>
      <pubDate>Fri, 24 Mar 2006 20:34:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/need-help/m-p/4968816#M101773</guid>
      <dc:creator>Sandman!</dc:creator>
      <dc:date>2006-03-24T20:34:57Z</dc:date>
    </item>
    <item>
      <title>Re: Need help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/need-help/m-p/4968817#M101774</link>
      <description>Thanks a lot guys ... I got the solution I wanted. It was a great help from all of you guys.&lt;BR /&gt;Thanks a lot.</description>
      <pubDate>Sun, 26 Mar 2006 23:18:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/need-help/m-p/4968817#M101774</guid>
      <dc:creator>suchitra</dc:creator>
      <dc:date>2006-03-26T23:18:23Z</dc:date>
    </item>
  </channel>
</rss>

