<?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: Help in script in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/help-in-script/m-p/4429505#M355533</link>
    <description>&lt;BR /&gt;&amp;gt; /tmp/different_files.txt #clean output file&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;for f in `cat file1`&lt;BR /&gt;do&lt;BR /&gt;grep -q "$f" file2&lt;BR /&gt;r=$?&lt;BR /&gt;if [ $r -ne 0 ]&lt;BR /&gt;then&lt;BR /&gt;echo $f &amp;gt;&amp;gt; /tmp/different_files.txt&lt;BR /&gt;fi&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;for f in `cat file2`&lt;BR /&gt;do&lt;BR /&gt;grep -q "$f" file1&lt;BR /&gt;r=$?&lt;BR /&gt;if [ $r -ne 0 ]&lt;BR /&gt;then&lt;BR /&gt;echo $f &amp;gt;&amp;gt; /tmp/different_files.txt&lt;BR /&gt;fi&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;This is not the most elaborate way of doing what you want but most explicit way so that you can follow and understand, then if necessary, modify it. Ask if you have any questions</description>
    <pubDate>Fri, 29 May 2009 18:30:11 GMT</pubDate>
    <dc:creator>Mel Burslan</dc:creator>
    <dc:date>2009-05-29T18:30:11Z</dc:date>
    <item>
      <title>Help in script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-in-script/m-p/4429504#M355532</link>
      <description>I have two files. Each file has listing of directories and I want two compare what is missing in each directory. i-e Some file names are common in both lists and some are different, I just want to know what files are different in each list.&lt;BR /&gt;&lt;BR /&gt;Can some one please help me in writing a script to accomplish that?&lt;BR /&gt;</description>
      <pubDate>Fri, 29 May 2009 18:19:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-in-script/m-p/4429504#M355532</guid>
      <dc:creator>Waqar Razi</dc:creator>
      <dc:date>2009-05-29T18:19:32Z</dc:date>
    </item>
    <item>
      <title>Re: Help in script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-in-script/m-p/4429505#M355533</link>
      <description>&lt;BR /&gt;&amp;gt; /tmp/different_files.txt #clean output file&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;for f in `cat file1`&lt;BR /&gt;do&lt;BR /&gt;grep -q "$f" file2&lt;BR /&gt;r=$?&lt;BR /&gt;if [ $r -ne 0 ]&lt;BR /&gt;then&lt;BR /&gt;echo $f &amp;gt;&amp;gt; /tmp/different_files.txt&lt;BR /&gt;fi&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;for f in `cat file2`&lt;BR /&gt;do&lt;BR /&gt;grep -q "$f" file1&lt;BR /&gt;r=$?&lt;BR /&gt;if [ $r -ne 0 ]&lt;BR /&gt;then&lt;BR /&gt;echo $f &amp;gt;&amp;gt; /tmp/different_files.txt&lt;BR /&gt;fi&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;This is not the most elaborate way of doing what you want but most explicit way so that you can follow and understand, then if necessary, modify it. Ask if you have any questions</description>
      <pubDate>Fri, 29 May 2009 18:30:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-in-script/m-p/4429505#M355533</guid>
      <dc:creator>Mel Burslan</dc:creator>
      <dc:date>2009-05-29T18:30:11Z</dc:date>
    </item>
    <item>
      <title>Re: Help in script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-in-script/m-p/4429506#M355534</link>
      <description>Hi Wagar:&lt;BR /&gt;&lt;BR /&gt;If you can sort (or don't mind sorting) the two files, then you can use 'comm' to make your comparisons.&lt;BR /&gt;&lt;BR /&gt;If you want to compare the contents of two directories, you can use 'diff'.&lt;BR /&gt;&lt;BR /&gt;See the manpages for these commands for more information.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Fri, 29 May 2009 18:35:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-in-script/m-p/4429506#M355534</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-05-29T18:35:15Z</dc:date>
    </item>
    <item>
      <title>Re: Help in script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-in-script/m-p/4429507#M355535</link>
      <description>Hi Waqar,&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;lets assume you have two files contains file names&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;firstfile&lt;BR /&gt;---------&lt;BR /&gt;abc&lt;BR /&gt;def&lt;BR /&gt;fgi&lt;BR /&gt;abc&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;secondfile&lt;BR /&gt;---------&lt;BR /&gt;abc&lt;BR /&gt;def&lt;BR /&gt;ghi&lt;BR /&gt;abc&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;&amp;gt;present_in_second_not_in_first&lt;BR /&gt;&amp;gt;present_in_first_not_in_second&lt;BR /&gt;&amp;gt;common&lt;BR /&gt;cat firstfile |sort|uniq &amp;gt;firtfile_last&lt;BR /&gt;cat secondfile |sort |uniq &amp;gt;secondfile_last&lt;BR /&gt;cat firstfile_last |while read line&lt;BR /&gt;do&lt;BR /&gt;grep -x "line" secondfile_last |read dummy  # you can remove -x option as it will look for exact line matching&lt;BR /&gt;if [ "$?" = "0" ] ;then&lt;BR /&gt;echo $line &amp;gt;&amp;gt;present_in_first_not_in_second&lt;BR /&gt;else&lt;BR /&gt;echo $line &amp;gt;&amp;gt;common&lt;BR /&gt;fi&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;cat secondfile_last |while read line&lt;BR /&gt;do&lt;BR /&gt;grep -x "line" firstfile_last |read dummy&lt;BR /&gt;if [ "$?" != "0" ] ; then&lt;BR /&gt;echo $line &amp;gt;&amp;gt;present_in_second_not_in_first&lt;BR /&gt;fi&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;it will give you three files&lt;BR /&gt;common --- common entries in both&lt;BR /&gt;present_in_second_not_in_first---- present in second file but not in first file&lt;BR /&gt;&lt;BR /&gt;present_in_first_not_in_second---- present in first file but not in second file&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Note:tested ..feel free to tell me if it is not working&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Rgds&lt;BR /&gt;Johnson&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 29 May 2009 19:31:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-in-script/m-p/4429507#M355535</guid>
      <dc:creator>johnsonpk</dc:creator>
      <dc:date>2009-05-29T19:31:03Z</dc:date>
    </item>
    <item>
      <title>Re: Help in script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-in-script/m-p/4429508#M355536</link>
      <description>Please try this one as the previous one has typo&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;&amp;gt;present_in_second_not_in_first&lt;BR /&gt;&amp;gt;present_in_first_not_in_second&lt;BR /&gt;&amp;gt;common&lt;BR /&gt;cat firstfile |sort|uniq &amp;gt;firstfile_last&lt;BR /&gt;cat secondfile |sort |uniq &amp;gt;secondfile_last&lt;BR /&gt;cat firstfile_last |while read line&lt;BR /&gt;do&lt;BR /&gt;grep -x "line" secondfile_last |read dummy # you can remove -x option as it will look for exact line matching&lt;BR /&gt;if [ "$?" = "0" ] ;then&lt;BR /&gt;echo $line &amp;gt;&amp;gt;common&lt;BR /&gt;else&lt;BR /&gt;echo $line &amp;gt;&amp;gt;present_in_first_not_in_second&lt;BR /&gt;fi&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;cat secondfile_last |while read line&lt;BR /&gt;do&lt;BR /&gt;grep -x "line" firstfile_last |read dummy&lt;BR /&gt;if [ "$?" != "0" ] ; then&lt;BR /&gt;echo $line &amp;gt;&amp;gt;present_in_second_not_in_first&lt;BR /&gt;fi&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Rgds&lt;BR /&gt;Johnson&lt;BR /&gt;</description>
      <pubDate>Fri, 29 May 2009 19:36:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-in-script/m-p/4429508#M355536</guid>
      <dc:creator>johnsonpk</dc:creator>
      <dc:date>2009-05-29T19:36:10Z</dc:date>
    </item>
    <item>
      <title>Re: Help in script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-in-script/m-p/4429509#M355537</link>
      <description>&amp;gt;Mel: This is not the most elaborate way of doing what you want but most explicit way so that you can follow and understand&lt;BR /&gt;&lt;BR /&gt;Unfortunately this is the worst way performance wise, it doesn't use vector methods and is N squared.  (I won't mention the evil cat and ``. ;-)&lt;BR /&gt;&lt;BR /&gt;As JRF said, sort both files then use comm:&lt;BR /&gt;sort file1 &amp;gt; file1.sort&lt;BR /&gt;sort file2 &amp;gt; file2.sort&lt;BR /&gt;comm -3 file1.sort file2.sort&lt;BR /&gt;&lt;BR /&gt;&amp;gt;Johnson: lets assume you have two files contains file names&lt;BR /&gt;&lt;BR /&gt;Directories don't have duplicates so you don't need uniq(1).  (And sort has -u.)&lt;BR /&gt;&lt;BR /&gt;&amp;gt;present_in_second_not_in_first&lt;BR /&gt;&amp;gt;present_in_first_not_in_second&lt;BR /&gt;&amp;gt;common&lt;BR /&gt;&lt;BR /&gt;To get these you simply do the following with my files above:&lt;BR /&gt;comm -13 file1.sort file2.sort &amp;gt; present_in_second_not_in_first&lt;BR /&gt;comm -23 file1.sort file2.sort &amp;gt; present_in_first_not_in_second&lt;BR /&gt;comm -12 file1.sort file2.sort &amp;gt; common</description>
      <pubDate>Sat, 30 May 2009 08:29:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-in-script/m-p/4429509#M355537</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2009-05-30T08:29:27Z</dc:date>
    </item>
  </channel>
</rss>

