<?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: How to grep a string in particular colom? in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-grep-a-string-in-particular-colom/m-p/5083676#M441034</link>
    <description>&lt;!--!*#--&gt;You can do the following.  It will be slow if file1 has lots of records.&lt;BR /&gt;while read file1; do&lt;BR /&gt;   echo "Looking for: $file1"&lt;BR /&gt;   awk -F, -v PAT="$file1" '&lt;BR /&gt;   $1 ~ PAT { print $0 }' File2&lt;BR /&gt;done &amp;lt; File1&lt;BR /&gt;&lt;BR /&gt;If you have lots of records, you need to do vector/quantum methods.</description>
    <pubDate>Tue, 11 Dec 2007 11:12:10 GMT</pubDate>
    <dc:creator>Dennis Handly</dc:creator>
    <dc:date>2007-12-11T11:12:10Z</dc:date>
    <item>
      <title>How to grep a string in particular colom?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-grep-a-string-in-particular-colom/m-p/5083674#M441032</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I am having two files.&lt;BR /&gt;&lt;BR /&gt;Files1 is having entries like:&lt;BR /&gt;&lt;BR /&gt;Region&lt;BR /&gt;"101"&lt;BR /&gt;"102"&lt;BR /&gt;"103"&lt;BR /&gt;and so on. Having unique records.&lt;BR /&gt;&lt;BR /&gt;Other file:&lt;BR /&gt;&lt;BR /&gt;File2:&lt;BR /&gt;&lt;BR /&gt;Region  site description&lt;BR /&gt;"101","ddd","this is region 101"&lt;BR /&gt;"101","ddc","this was region"&lt;BR /&gt;"102","dda","this gg region102"&lt;BR /&gt;"102","ddn","this oo region"&lt;BR /&gt;and so on(Having dulicate region values)".&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I want to take record one by one from file 1 and grep only in first fileld of file2 and output the results in other file.&lt;BR /&gt;&lt;BR /&gt;Can some suggest how to do this?&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 11 Dec 2007 10:19:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-grep-a-string-in-particular-colom/m-p/5083674#M441032</guid>
      <dc:creator>N Gopal</dc:creator>
      <dc:date>2007-12-11T10:19:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to grep a string in particular colom?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-grep-a-string-in-particular-colom/m-p/5083675#M441033</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;you can use "awk" to take only the first column from the file.&lt;BR /&gt;Use something like this:&lt;BR /&gt;&lt;BR /&gt;awk -F"," '{ print $1 }' path_to_file2&lt;BR /&gt;&lt;BR /&gt;where "," is the separator between the columns</description>
      <pubDate>Tue, 11 Dec 2007 11:11:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-grep-a-string-in-particular-colom/m-p/5083675#M441033</guid>
      <dc:creator>Delcho Tuhchiev</dc:creator>
      <dc:date>2007-12-11T11:11:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to grep a string in particular colom?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-grep-a-string-in-particular-colom/m-p/5083676#M441034</link>
      <description>&lt;!--!*#--&gt;You can do the following.  It will be slow if file1 has lots of records.&lt;BR /&gt;while read file1; do&lt;BR /&gt;   echo "Looking for: $file1"&lt;BR /&gt;   awk -F, -v PAT="$file1" '&lt;BR /&gt;   $1 ~ PAT { print $0 }' File2&lt;BR /&gt;done &amp;lt; File1&lt;BR /&gt;&lt;BR /&gt;If you have lots of records, you need to do vector/quantum methods.</description>
      <pubDate>Tue, 11 Dec 2007 11:12:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-grep-a-string-in-particular-colom/m-p/5083676#M441034</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2007-12-11T11:12:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to grep a string in particular colom?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-grep-a-string-in-particular-colom/m-p/5083677#M441035</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I am agin simplyfying my question.&lt;BR /&gt;&lt;BR /&gt;My code should be like.&lt;BR /&gt;&lt;BR /&gt;while read line&lt;BR /&gt;&lt;BR /&gt;do&lt;BR /&gt;&lt;BR /&gt;grep "$line" file2 &amp;gt;&amp;gt; output.txt&lt;BR /&gt;&lt;BR /&gt;done &amp;lt; file1&lt;BR /&gt;&lt;BR /&gt;i want to something like that. But i want to grep region value in first field of file 2 (because that string may be present in some other colom also that i do not want to take.)and out complte line corresponding to that in out put file.&lt;BR /&gt;&lt;BR /&gt;We can say files are of normal size then can you suggest how to do.&lt;BR /&gt;&lt;BR /&gt;out file file should have record like :&lt;BR /&gt;"101","ddd","this is region 101"&lt;BR /&gt;"101","ddc","this was region"&lt;BR /&gt;"102","dda","this gg region102"&lt;BR /&gt;&lt;BR /&gt;Thanks</description>
      <pubDate>Tue, 11 Dec 2007 11:27:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-grep-a-string-in-particular-colom/m-p/5083677#M441035</guid>
      <dc:creator>N Gopal</dc:creator>
      <dc:date>2007-12-11T11:27:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to grep a string in particular colom?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-grep-a-string-in-particular-colom/m-p/5083678#M441036</link>
      <description>&lt;!--!*#--&gt;&amp;gt;We can say files are of normal size then can you suggest how to do.&lt;BR /&gt;&lt;BR /&gt;I suggested how to do it.  If you don't want the title you can do:&lt;BR /&gt;   awk -F, -v PAT="$file1" '&lt;BR /&gt;   BEGIN { getline }&lt;BR /&gt;   $1 ~ PAT { print $0 }' File2&lt;BR /&gt;&lt;BR /&gt;You should leave out that debugging "echo".</description>
      <pubDate>Tue, 11 Dec 2007 11:40:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-grep-a-string-in-particular-colom/m-p/5083678#M441036</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2007-12-11T11:40:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to grep a string in particular colom?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-grep-a-string-in-particular-colom/m-p/5083679#M441037</link>
      <description>Many thanks Dennis,&lt;BR /&gt;&lt;BR /&gt;It is working fine.&lt;BR /&gt;Can i redirect the out put to output file as i want this?&lt;BR /&gt;&lt;BR /&gt;while read file1; do&lt;BR /&gt;   echo "Looking for: $file1"&lt;BR /&gt;   awk -F, -v PAT="$file1" '&lt;BR /&gt;   $1 ~ PAT { print $0 }' File2 &amp;gt;&amp;gt; output.txt&lt;BR /&gt;done &amp;lt; File1&lt;BR /&gt;&lt;BR /&gt;Thanks</description>
      <pubDate>Tue, 11 Dec 2007 12:09:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-grep-a-string-in-particular-colom/m-p/5083679#M441037</guid>
      <dc:creator>N Gopal</dc:creator>
      <dc:date>2007-12-11T12:09:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to grep a string in particular colom?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-grep-a-string-in-particular-colom/m-p/5083680#M441038</link>
      <description>Hi Dennis,&lt;BR /&gt;&lt;BR /&gt;Applogies one more clarification.&lt;BR /&gt;In this case i am greping string in first field in File2. If would be 3field in File2 then where i have to make changes.&lt;BR /&gt;&lt;BR /&gt;Thanks</description>
      <pubDate>Tue, 11 Dec 2007 12:21:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-grep-a-string-in-particular-colom/m-p/5083680#M441038</guid>
      <dc:creator>N Gopal</dc:creator>
      <dc:date>2007-12-11T12:21:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to grep a string in particular colom?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-grep-a-string-in-particular-colom/m-p/5083681#M441039</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;&amp;gt; In this case i am greping string in first field in File2. If would be 3field in File2 then where i have to make changes.&lt;BR /&gt;&lt;BR /&gt;Then, change:&lt;BR /&gt;&lt;BR /&gt;$1 ~ PAT { print $0 }' File2 &amp;gt;&amp;gt; output.txt&lt;BR /&gt;&lt;BR /&gt;To:&lt;BR /&gt;&lt;BR /&gt;$3 ~ PAT { print $0 }' File2 &amp;gt;&amp;gt; output.txt&lt;BR /&gt;&lt;BR /&gt;'awk' numbers fields counting from one (1) with '$0' representing the whole line (record).&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 11 Dec 2007 13:06:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-grep-a-string-in-particular-colom/m-p/5083681#M441039</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-12-11T13:06:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to grep a string in particular colom?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-grep-a-string-in-particular-colom/m-p/5083682#M441040</link>
      <description>If your files are sorted then you can simply use join(1) to get the desired output.&lt;BR /&gt;&lt;BR /&gt;# join -t, -j1 1 -j2 1 -o 2.1 2.2 2.3 file1 file2 &amp;gt; output.txt&lt;BR /&gt;&lt;BR /&gt;...otherwise sort file1 and file2 before using them in a join(1) viz.,&lt;BR /&gt;&lt;BR /&gt;# sort -k1,1 file1 &amp;gt; srtd1&lt;BR /&gt;# sort -t, -k1,1 file2 &amp;gt; srtd2&lt;BR /&gt;# join -t, -j1 1 -j2 1 -o 2.1 2.2 2.3 srtd1 srtd2 &amp;gt; output.txt</description>
      <pubDate>Tue, 11 Dec 2007 15:57:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-grep-a-string-in-particular-colom/m-p/5083682#M441040</guid>
      <dc:creator>Sandman!</dc:creator>
      <dc:date>2007-12-11T15:57:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to grep a string in particular colom?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-grep-a-string-in-particular-colom/m-p/5083683#M441041</link>
      <description>&amp;gt;Can i redirect the out put to output file as i want this?&lt;BR /&gt;&lt;BR /&gt;while read file1; do&lt;BR /&gt;...&lt;BR /&gt;done &amp;lt; File1 &amp;gt; output.txt&lt;BR /&gt;&lt;BR /&gt;You can redirect the whole "while" output rather than opening the file once per loop.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;If would be 3 field in File2 then where i have to make changes.&lt;BR /&gt;&lt;BR /&gt;You would have problems because of the quotes.  They would have to be removed:&lt;BR /&gt;BEGIN { getline; gsub("\"", "", PAT) }&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 11 Dec 2007 22:48:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-grep-a-string-in-particular-colom/m-p/5083683#M441041</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2007-12-11T22:48:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to grep a string in particular colom?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-grep-a-string-in-particular-colom/m-p/5083684#M441042</link>
      <description>Hi All,&lt;BR /&gt;&lt;BR /&gt;Thanks a lot for your valuable replies. I got my answer.&lt;BR /&gt;&lt;BR /&gt;Thanks again.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 12 Dec 2007 05:47:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-grep-a-string-in-particular-colom/m-p/5083684#M441042</guid>
      <dc:creator>N Gopal</dc:creator>
      <dc:date>2007-12-12T05:47:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to grep a string in particular colom?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-grep-a-string-in-particular-colom/m-p/5083685#M441043</link>
      <description>I got satisfactory answer for my query.&lt;BR /&gt;&lt;BR /&gt;Thanks a lot for help.</description>
      <pubDate>Wed, 12 Dec 2007 05:48:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-grep-a-string-in-particular-colom/m-p/5083685#M441043</guid>
      <dc:creator>N Gopal</dc:creator>
      <dc:date>2007-12-12T05:48:42Z</dc:date>
    </item>
  </channel>
</rss>

