<?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: Check file existence command in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/check-file-existence-command/m-p/4642484#M676567</link>
    <description>Hello,&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;echo At the begining of each line -separated by :- there is the line no &amp;gt;results.txt&lt;BR /&gt;echo of the file2.txt where the word read from file1.txt was found  &amp;gt;&amp;gt;results.txt&lt;BR /&gt;echo  &amp;gt;&amp;gt;results.txt&lt;BR /&gt;for WORD in $(awk '{print $1}' file1.txt)&lt;BR /&gt;do&lt;BR /&gt;echo For $WORD:  &amp;gt;&amp;gt;results.txt&lt;BR /&gt;grep -n $WORD file2.txt &amp;gt;&amp;gt;results.txt&lt;BR /&gt;echo  &amp;gt;&amp;gt;results.txt&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Best regards,&lt;BR /&gt;Horia.&lt;BR /&gt;</description>
    <pubDate>Fri, 04 Jun 2010 06:24:37 GMT</pubDate>
    <dc:creator>Horia Chirculescu</dc:creator>
    <dc:date>2010-06-04T06:24:37Z</dc:date>
    <item>
      <title>Check file existence command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/check-file-existence-command/m-p/4642481#M676564</link>
      <description>I have a file as below , there is 800 lines in it .&lt;BR /&gt;vi file1.txt&lt;BR /&gt;aaa&lt;BR /&gt;bbb&lt;BR /&gt;ccc&lt;BR /&gt;ddd&lt;BR /&gt;"&lt;BR /&gt;"&lt;BR /&gt;&lt;BR /&gt;I have another file as below ( this is a large text file )&lt;BR /&gt;vi file2.txt&lt;BR /&gt;#fdasfasfasfasfashklfasfbb7x&lt;BR /&gt;7fd097af0as78fasfdaaaasgafs&lt;BR /&gt;867f9as78f98abbbf96fdsafas&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Now , I would like to check each line in the file1.txt whether exists in the file2.txt , that means I would like to know whether aaa exists in file2.txt , and bbb exists in file2.txt , and ccc exists in file2.txt ... or not , I don't want to do it 800 times , can advise what can i do ? thx</description>
      <pubDate>Fri, 04 Jun 2010 05:45:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/check-file-existence-command/m-p/4642481#M676564</guid>
      <dc:creator>ivy1234</dc:creator>
      <dc:date>2010-06-04T05:45:55Z</dc:date>
    </item>
    <item>
      <title>Re: Check file existence command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/check-file-existence-command/m-p/4642482#M676565</link>
      <description>hi&lt;BR /&gt;&lt;BR /&gt;u can use diff &lt;BR /&gt;&lt;BR /&gt;diff /file1.txt file2.txt&lt;BR /&gt;&lt;BR /&gt;regards&lt;BR /&gt;&lt;BR /&gt;MC</description>
      <pubDate>Fri, 04 Jun 2010 06:12:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/check-file-existence-command/m-p/4642482#M676565</guid>
      <dc:creator>madhuchakkaravarthy</dc:creator>
      <dc:date>2010-06-04T06:12:59Z</dc:date>
    </item>
    <item>
      <title>Re: Check file existence command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/check-file-existence-command/m-p/4642483#M676566</link>
      <description>you want to see if any string in file1 is in file2&lt;BR /&gt;or all string in file1 is in file2?&lt;BR /&gt;or which string in file1 is in file2?</description>
      <pubDate>Fri, 04 Jun 2010 06:19:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/check-file-existence-command/m-p/4642483#M676566</guid>
      <dc:creator>Laurent Menase</dc:creator>
      <dc:date>2010-06-04T06:19:30Z</dc:date>
    </item>
    <item>
      <title>Re: Check file existence command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/check-file-existence-command/m-p/4642484#M676567</link>
      <description>Hello,&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;echo At the begining of each line -separated by :- there is the line no &amp;gt;results.txt&lt;BR /&gt;echo of the file2.txt where the word read from file1.txt was found  &amp;gt;&amp;gt;results.txt&lt;BR /&gt;echo  &amp;gt;&amp;gt;results.txt&lt;BR /&gt;for WORD in $(awk '{print $1}' file1.txt)&lt;BR /&gt;do&lt;BR /&gt;echo For $WORD:  &amp;gt;&amp;gt;results.txt&lt;BR /&gt;grep -n $WORD file2.txt &amp;gt;&amp;gt;results.txt&lt;BR /&gt;echo  &amp;gt;&amp;gt;results.txt&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Best regards,&lt;BR /&gt;Horia.&lt;BR /&gt;</description>
      <pubDate>Fri, 04 Jun 2010 06:24:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/check-file-existence-command/m-p/4642484#M676567</guid>
      <dc:creator>Horia Chirculescu</dc:creator>
      <dc:date>2010-06-04T06:24:37Z</dc:date>
    </item>
    <item>
      <title>Re: Check file existence command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/check-file-existence-command/m-p/4642485#M676568</link>
      <description>for i in `cat file1.txt`&lt;BR /&gt;do&lt;BR /&gt;grep -q $i file2.txt&lt;BR /&gt;if [ ? = 0 ]&lt;BR /&gt;   then&lt;BR /&gt;   echo "$i-------------exits in file"&lt;BR /&gt;   else&lt;BR /&gt;   echo "$i-------------do not exist"&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;it is a small script you can adapt it according to you need.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 04 Jun 2010 06:25:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/check-file-existence-command/m-p/4642485#M676568</guid>
      <dc:creator>singh sanjeev</dc:creator>
      <dc:date>2010-06-04T06:25:13Z</dc:date>
    </item>
    <item>
      <title>Re: Check file existence command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/check-file-existence-command/m-p/4642486#M676569</link>
      <description>Notice the use of awk! It means that if you want you can add on file1 comments like this:&lt;BR /&gt;&lt;BR /&gt;cat file1.txt&lt;BR /&gt;&lt;BR /&gt;aaa The first word that is to be searched&lt;BR /&gt;bbb My son's name. Where on earth is he now?&lt;BR /&gt;ccc My wife's name. She's not in the kitchen.&lt;BR /&gt;ddd I am starving!&lt;BR /&gt;&lt;BR /&gt;Best regards from Romania&lt;BR /&gt;Horia.</description>
      <pubDate>Fri, 04 Jun 2010 06:31:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/check-file-existence-command/m-p/4642486#M676569</guid>
      <dc:creator>Horia Chirculescu</dc:creator>
      <dc:date>2010-06-04T06:31:40Z</dc:date>
    </item>
    <item>
      <title>Re: Check file existence command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/check-file-existence-command/m-p/4642487#M676570</link>
      <description>Hi ,&lt;BR /&gt;&lt;BR /&gt;it seems very simple , so I tried it , but I got the error message "line 10: syntax error: unexpected end of file , can advise what is wrong ?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;for i in `cat file1.txt`&lt;BR /&gt;do&lt;BR /&gt;grep -q $i file2.txt&lt;BR /&gt;if [ ? = 0 ]&lt;BR /&gt;then&lt;BR /&gt;echo "$i-------------exits in file"&lt;BR /&gt;else&lt;BR /&gt;echo "$i-------------do not exist"&lt;BR /&gt;fi</description>
      <pubDate>Fri, 04 Jun 2010 07:13:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/check-file-existence-command/m-p/4642487#M676570</guid>
      <dc:creator>ivy1234</dc:creator>
      <dc:date>2010-06-04T07:13:32Z</dc:date>
    </item>
    <item>
      <title>Re: Check file existence command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/check-file-existence-command/m-p/4642488#M676571</link>
      <description>Lil modification....&lt;BR /&gt;&lt;BR /&gt;for i in `cat file1.txt` &lt;BR /&gt;do &lt;BR /&gt;grep -q $i file2.txt &lt;BR /&gt;if [ $? == 0 ]  &lt;BR /&gt;then &lt;BR /&gt;echo "$i-------------exits in file" &lt;BR /&gt;else &lt;BR /&gt;echo "$i-------------do not exist" &lt;BR /&gt;fi&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;You can supress the second line &lt;BR /&gt;&amp;gt;echo "$i-------------do not exist"   to&lt;BR /&gt;echo ""&lt;BR /&gt;&lt;BR /&gt;BR,&lt;BR /&gt;Kapil+</description>
      <pubDate>Fri, 04 Jun 2010 08:13:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/check-file-existence-command/m-p/4642488#M676571</guid>
      <dc:creator>Kapil Jha</dc:creator>
      <dc:date>2010-06-04T08:13:14Z</dc:date>
    </item>
    <item>
      <title>Re: Check file existence command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/check-file-existence-command/m-p/4642489#M676572</link>
      <description>OOps it should be&lt;BR /&gt;if [ $? = 0 ]  insted of &lt;BR /&gt;if [ $? == 0 ] &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;BR,&lt;BR /&gt;Kapil+</description>
      <pubDate>Fri, 04 Jun 2010 08:15:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/check-file-existence-command/m-p/4642489#M676572</guid>
      <dc:creator>Kapil Jha</dc:creator>
      <dc:date>2010-06-04T08:15:06Z</dc:date>
    </item>
    <item>
      <title>Re: Check file existence command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/check-file-existence-command/m-p/4642490#M676573</link>
      <description>Hi &lt;BR /&gt;Use comm command this is an usefull command to compare files.&lt;BR /&gt;use&lt;BR /&gt;comm -12 file1.txt and file2.txt &lt;BR /&gt;&lt;BR /&gt;This will list contents which exists in both files&lt;BR /&gt;&lt;BR /&gt;Sagar</description>
      <pubDate>Fri, 04 Jun 2010 10:21:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/check-file-existence-command/m-p/4642490#M676573</guid>
      <dc:creator>Sagar Sirdesai</dc:creator>
      <dc:date>2010-06-04T10:21:14Z</dc:date>
    </item>
    <item>
      <title>Re: Check file existence command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/check-file-existence-command/m-p/4642491#M676574</link>
      <description>&lt;P&gt;You could use fgrep -f:&lt;BR /&gt;fgrep -f file1.txt file2.txt&lt;BR /&gt;&lt;BR /&gt;&amp;gt;Kapil: it should be if [ $? = 0 ]&lt;BR /&gt;&lt;BR /&gt;No, actually it should be: if [ $? -eq 0 ]&lt;BR /&gt;&lt;BR /&gt;&amp;gt;Sagar: Use comm command this is an useful command to compare files.&lt;BR /&gt;&lt;BR /&gt;This only works if the files are sorted.&lt;/P&gt;</description>
      <pubDate>Sun, 02 Oct 2011 02:42:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/check-file-existence-command/m-p/4642491#M676574</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2011-10-02T02:42:40Z</dc:date>
    </item>
  </channel>
</rss>

