<?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 scripting in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/help-scripting/m-p/3537604#M701656</link>
    <description>Hi Vogra;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=754581" target="_blank"&gt;http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=754581&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;i have asked before and found very interesting solutions.&lt;BR /&gt;&lt;BR /&gt;Good Luck;</description>
    <pubDate>Thu, 05 May 2005 09:38:24 GMT</pubDate>
    <dc:creator>Cem Tugrul</dc:creator>
    <dc:date>2005-05-05T09:38:24Z</dc:date>
    <item>
      <title>Help scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-scripting/m-p/3537597#M701649</link>
      <description>Hi All!&lt;BR /&gt;i have 2 files and  i need check one with the contents that exist in another.&lt;BR /&gt;&lt;BR /&gt;lista1.txt and lista2.txt&lt;BR /&gt;&lt;BR /&gt;like this:&lt;BR /&gt;&lt;BR /&gt;for each line in lista1.txt&lt;BR /&gt;do&lt;BR /&gt; is it equal any line in lista2.txt ?&lt;BR /&gt; send line to lista3.txt&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Lima.</description>
      <pubDate>Wed, 04 May 2005 09:46:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-scripting/m-p/3537597#M701649</guid>
      <dc:creator>Vogra</dc:creator>
      <dc:date>2005-05-04T09:46:49Z</dc:date>
    </item>
    <item>
      <title>Re: Help scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-scripting/m-p/3537598#M701650</link>
      <description>for i in $(&lt;FILE1&gt;&lt;/FILE1&gt;do&lt;BR /&gt;grep -iq "grep_string" file2 &amp;gt; /dev/null 2&amp;gt;&amp;amp;1&lt;BR /&gt;if [[ $? -eq 0 ]]&lt;BR /&gt;then&lt;BR /&gt;echo ${i} &amp;gt;&amp;gt; file3&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;Also check comm, diff, uniq commands.&lt;BR /&gt;&lt;BR /&gt;comm -12 file1 file2 &amp;gt; file3&lt;BR /&gt;&lt;BR /&gt;Anil</description>
      <pubDate>Wed, 04 May 2005 09:53:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-scripting/m-p/3537598#M701650</guid>
      <dc:creator>RAC_1</dc:creator>
      <dc:date>2005-05-04T09:53:59Z</dc:date>
    </item>
    <item>
      <title>Re: Help scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-scripting/m-p/3537599#M701651</link>
      <description>cat lista1.txt |while read line&lt;BR /&gt;do&lt;BR /&gt;grep "$line" lista2.txt &amp;gt;&amp;gt; lista3.txt&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Kaps&lt;BR /&gt;</description>
      <pubDate>Wed, 04 May 2005 10:01:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-scripting/m-p/3537599#M701651</guid>
      <dc:creator>KapilRaj</dc:creator>
      <dc:date>2005-05-04T10:01:27Z</dc:date>
    </item>
    <item>
      <title>Re: Help scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-scripting/m-p/3537600#M701652</link>
      <description>I would leverage the comm comand for this. This should do it:&lt;BR /&gt;----------------------------------------&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;typeset TDIR=${TMPDIR:-/var/tmp}&lt;BR /&gt;typeset T1=${TDIR}/T${$}_1.txt&lt;BR /&gt;typeset T2=${TDIR}/T${$}_2.txt&lt;BR /&gt;&lt;BR /&gt;typeset PROG=${0##*/}&lt;BR /&gt;&lt;BR /&gt;trap 'eval rm -f ${T1} ${T2}' 0 1 2 15&lt;BR /&gt;&lt;BR /&gt;typeset -i STAT=0&lt;BR /&gt;if [[ ${#} -eq 2 ]]&lt;BR /&gt;  then&lt;BR /&gt;    typeset F1=${1}&lt;BR /&gt;    typeset F2=${2}&lt;BR /&gt;    shift 2&lt;BR /&gt;    if [[ -r ${F1} &amp;amp;&amp;amp; -r ${F2} ]]&lt;BR /&gt;      then&lt;BR /&gt;        sort ${F1} &amp;gt; ${T1}&lt;BR /&gt;        sort ${F2} &amp;gt; ${T2}&lt;BR /&gt;        comm -12 ${T1} ${T2} &lt;BR /&gt;      else&lt;BR /&gt;        echo "Can't read file ${F1} and/or ${F2}." &amp;gt;&amp;amp;2&lt;BR /&gt;        STAT=254&lt;BR /&gt;      fi&lt;BR /&gt;  else&lt;BR /&gt;    echo "${PROG} requires 2 args" &amp;gt;&amp;amp;2&lt;BR /&gt;    STAT=255&lt;BR /&gt;  fi&lt;BR /&gt;exit ${STAT}&lt;BR /&gt;&lt;BR /&gt;---------------------------------------&lt;BR /&gt;&lt;BR /&gt;Use it like this:&lt;BR /&gt;&lt;BR /&gt;comm.sh lista1.txt lista2.txt &amp;gt; lista3.txt &lt;BR /&gt;</description>
      <pubDate>Wed, 04 May 2005 10:05:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-scripting/m-p/3537600#M701652</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2005-05-04T10:05:41Z</dc:date>
    </item>
    <item>
      <title>Re: Help scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-scripting/m-p/3537601#M701653</link>
      <description>thank you so much!</description>
      <pubDate>Wed, 04 May 2005 10:07:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-scripting/m-p/3537601#M701653</guid>
      <dc:creator>Vogra</dc:creator>
      <dc:date>2005-05-04T10:07:19Z</dc:date>
    </item>
    <item>
      <title>Re: Help scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-scripting/m-p/3537602#M701654</link>
      <description>Lima, &lt;BR /&gt;Try this, it works&lt;BR /&gt;&lt;BR /&gt;sort lista1.txt |uniq &amp;gt;l1.txt&lt;BR /&gt;sort lista2.txt |uniq &amp;gt;l2.txt&lt;BR /&gt;cat l1.txt l2.txt |uniq -c | awk '$1&amp;gt;1 {print}' |cut -f2- " "&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;HTH</description>
      <pubDate>Wed, 04 May 2005 10:14:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-scripting/m-p/3537602#M701654</guid>
      <dc:creator>Victor Fridyev</dc:creator>
      <dc:date>2005-05-04T10:14:31Z</dc:date>
    </item>
    <item>
      <title>Re: Help scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-scripting/m-p/3537603#M701655</link>
      <description>Why not use file 2 as a pattern file?&lt;BR /&gt;&lt;BR /&gt;grep -f lista2.txt lista1.txt &amp;gt; lista3.txt&lt;BR /&gt;&lt;BR /&gt;Example:&lt;BR /&gt;&lt;BR /&gt;$ cat x1&lt;BR /&gt;aap&lt;BR /&gt;noot&lt;BR /&gt;mies&lt;BR /&gt;teun&lt;BR /&gt;$ cat x2&lt;BR /&gt;mies&lt;BR /&gt;noot&lt;BR /&gt;vuur&lt;BR /&gt;$ grep -f x2 x1&lt;BR /&gt;noot&lt;BR /&gt;mies&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;hth,&lt;BR /&gt;   Hein.&lt;BR /&gt;</description>
      <pubDate>Wed, 04 May 2005 11:19:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-scripting/m-p/3537603#M701655</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2005-05-04T11:19:36Z</dc:date>
    </item>
    <item>
      <title>Re: Help scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-scripting/m-p/3537604#M701656</link>
      <description>Hi Vogra;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=754581" target="_blank"&gt;http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=754581&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;i have asked before and found very interesting solutions.&lt;BR /&gt;&lt;BR /&gt;Good Luck;</description>
      <pubDate>Thu, 05 May 2005 09:38:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-scripting/m-p/3537604#M701656</guid>
      <dc:creator>Cem Tugrul</dc:creator>
      <dc:date>2005-05-05T09:38:24Z</dc:date>
    </item>
    <item>
      <title>Re: Help scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-scripting/m-p/3537605#M701657</link>
      <description>I like this simple solution like Kapil solution&lt;BR /&gt;cat lista1.txt |while read var&lt;BR /&gt;do&lt;BR /&gt;grep "$var" lista2.txt &amp;gt;&amp;gt; lista3.txt&lt;BR /&gt;done&lt;BR /&gt;HTH&lt;BR /&gt;tienna</description>
      <pubDate>Fri, 06 May 2005 02:05:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-scripting/m-p/3537605#M701657</guid>
      <dc:creator>Nguyen Anh Tien</dc:creator>
      <dc:date>2005-05-06T02:05:52Z</dc:date>
    </item>
    <item>
      <title>Re: Help scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-scripting/m-p/3537606#M701658</link>
      <description>There is one issue with the above solutions. If there is a duplicate entry in file1, then it goes undetected using grep. &lt;BR /&gt;&lt;BR /&gt;$ cat file1&lt;BR /&gt;aaa&lt;BR /&gt;bbb&lt;BR /&gt;aaa&lt;BR /&gt;$ cat file2&lt;BR /&gt;aaa&lt;BR /&gt;bbb&lt;BR /&gt;ccc&lt;BR /&gt;&lt;BR /&gt;The above solution would still show that file2 contains file1,which is incorrcet. &lt;BR /&gt;&lt;BR /&gt;I believe the best solution would be to sort the two files and then use diff. &lt;BR /&gt;&lt;BR /&gt;$ cat compare.sh&lt;BR /&gt;sort file1 -o file1.sort&lt;BR /&gt;sort file2 -o file2.sort&lt;BR /&gt;diff file1.sort file2.sort &amp;gt; /tmp/diffout&lt;BR /&gt;grep '^&amp;lt; ' /tmp/diffout&lt;BR /&gt;if [ $? -eq 0 ]&lt;BR /&gt;then&lt;BR /&gt;    echo "file1 is not a subset of file2"&lt;BR /&gt;else&lt;BR /&gt;    echo "file1 is subset of file2"&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;-Amit</description>
      <pubDate>Fri, 06 May 2005 02:19:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-scripting/m-p/3537606#M701658</guid>
      <dc:creator>Amit Agarwal_1</dc:creator>
      <dc:date>2005-05-06T02:19:23Z</dc:date>
    </item>
    <item>
      <title>Re: Help scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-scripting/m-p/3537607#M701659</link>
      <description>You can do as,&lt;BR /&gt;&lt;BR /&gt;&amp;gt; lista3.txt&lt;BR /&gt;while read line; do&lt;BR /&gt;&lt;BR /&gt;  grep $line lista2.txt &amp;gt;&amp;gt; lista3.txt&lt;BR /&gt;&lt;BR /&gt;done &amp;lt; lista1.txt&lt;BR /&gt;&lt;BR /&gt;grep will automatically print if the pattern in available in the file with that pattern.&lt;BR /&gt;&lt;BR /&gt;HTH.&lt;BR /&gt;</description>
      <pubDate>Fri, 06 May 2005 04:16:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-scripting/m-p/3537607#M701659</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2005-05-06T04:16:30Z</dc:date>
    </item>
  </channel>
</rss>

