<?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: grep command in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-command/m-p/4882575#M846516</link>
    <description>Grep does return the whole line when a pattern match is made. Im not sure I understand the application of your question.&lt;BR /&gt;&lt;BR /&gt;Are you trying to change the word or import it to another file or script?&lt;BR /&gt;&lt;BR /&gt;Maybe you can offer a bit more explanation...</description>
    <pubDate>Thu, 27 Jan 2005 17:05:25 GMT</pubDate>
    <dc:creator>Todd McDaniel_1</dc:creator>
    <dc:date>2005-01-27T17:05:25Z</dc:date>
    <item>
      <title>grep command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-command/m-p/4882574#M846515</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I am trying to grep a word "connect" in  files but grep command will return the entire line that contain the word "connect" in.&lt;BR /&gt;&lt;BR /&gt;For example:&lt;BR /&gt;file text.txt has the following line:&lt;BR /&gt;&lt;BR /&gt;"Uncomment the next line for more connect information */"&lt;BR /&gt;&lt;BR /&gt;Command:&lt;BR /&gt;$ grep connect  text.txt &lt;BR /&gt;&lt;BR /&gt;Will return the entire line.&lt;BR /&gt;&lt;BR /&gt;I would like to get just "more connect information" not the entire line or subset of the line but still contain the word "connect".&lt;BR /&gt;&lt;BR /&gt;Is there a way to do this in shell script?&lt;BR /&gt;&lt;BR /&gt;Thanks.&lt;BR /&gt;</description>
      <pubDate>Thu, 27 Jan 2005 16:33:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-command/m-p/4882574#M846515</guid>
      <dc:creator>Ridzuan Zakaria</dc:creator>
      <dc:date>2005-01-27T16:33:16Z</dc:date>
    </item>
    <item>
      <title>Re: grep command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-command/m-p/4882575#M846516</link>
      <description>Grep does return the whole line when a pattern match is made. Im not sure I understand the application of your question.&lt;BR /&gt;&lt;BR /&gt;Are you trying to change the word or import it to another file or script?&lt;BR /&gt;&lt;BR /&gt;Maybe you can offer a bit more explanation...</description>
      <pubDate>Thu, 27 Jan 2005 17:05:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-command/m-p/4882575#M846516</guid>
      <dc:creator>Todd McDaniel_1</dc:creator>
      <dc:date>2005-01-27T17:05:25Z</dc:date>
    </item>
    <item>
      <title>Re: grep command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-command/m-p/4882576#M846517</link>
      <description>Hi Todd,&lt;BR /&gt;&lt;BR /&gt;What I am trying to do is that instead of display the entire line from the grep output result, I would like to display subset of the return line.&lt;BR /&gt;&lt;BR /&gt;If "grep connect text.file" will return output:&lt;BR /&gt;"your connection to database abc failed"&lt;BR /&gt;&lt;BR /&gt;I would like to display just the "connection to database".&lt;BR /&gt;&lt;BR /&gt;Thanks.</description>
      <pubDate>Thu, 27 Jan 2005 17:14:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-command/m-p/4882576#M846517</guid>
      <dc:creator>Ridzuan Zakaria</dc:creator>
      <dc:date>2005-01-27T17:14:11Z</dc:date>
    </item>
    <item>
      <title>Re: grep command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-command/m-p/4882577#M846518</link>
      <description>one way is to use awk&lt;BR /&gt;&lt;BR /&gt;awk '&lt;BR /&gt;/^connect/ {&lt;BR /&gt;    if ( NF == 1 ) print $i;&lt;BR /&gt;    else print $i, $(i+1);&lt;BR /&gt;    next;&lt;BR /&gt;}&lt;BR /&gt;/connect$/ {&lt;BR /&gt;    print $(i-1), $i;&lt;BR /&gt;    next;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;/connect/ {&lt;BR /&gt;    for ( i=1;i&amp;lt;=NF;i++) {&lt;BR /&gt;        if ( $i ~ "connect" ) {break;}&lt;BR /&gt;    }&lt;BR /&gt;    print $(i-1), $i, $(i+1);&lt;BR /&gt;}' yourfile&lt;BR /&gt;&lt;BR /&gt;this will print the word before and after "connect". &lt;BR /&gt;&lt;BR /&gt;and i'm sure using perl's patteren matching capabilities would work much better.&lt;BR /&gt;</description>
      <pubDate>Thu, 27 Jan 2005 17:24:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-command/m-p/4882577#M846518</guid>
      <dc:creator>c_51</dc:creator>
      <dc:date>2005-01-27T17:24:32Z</dc:date>
    </item>
    <item>
      <title>Re: grep command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-command/m-p/4882578#M846519</link>
      <description>oops made some cut and paste errors&lt;BR /&gt;&lt;BR /&gt;awk '&lt;BR /&gt;/^connect/ {&lt;BR /&gt;if ( NF == 1 ) print $1;&lt;BR /&gt;else print $1, $2;&lt;BR /&gt;next;&lt;BR /&gt;}&lt;BR /&gt;/connect$/ {&lt;BR /&gt;print $(NF-1), $NF;&lt;BR /&gt;next;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;/connect/ {&lt;BR /&gt;for ( i=2;i&lt;NF&gt;&lt;/NF&gt;if ( $i ~ "connect" ) {break;}&lt;BR /&gt;}&lt;BR /&gt;print $(i-1), $i, $(i+1);&lt;BR /&gt;}' yourfile&lt;BR /&gt;</description>
      <pubDate>Thu, 27 Jan 2005 17:27:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-command/m-p/4882578#M846519</guid>
      <dc:creator>c_51</dc:creator>
      <dc:date>2005-01-27T17:27:52Z</dc:date>
    </item>
    <item>
      <title>Re: grep command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-command/m-p/4882579#M846520</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I'm not sure, that you can do what you want with grep only. If you know sructure of strings in the file, you can do either:&lt;BR /&gt;&lt;BR /&gt;grep connect text.txt | awk '{print $3,$4,$5}' or&lt;BR /&gt;grep connect text.txt |cut -c10-25&lt;BR /&gt;&lt;BR /&gt;HTH&lt;BR /&gt;</description>
      <pubDate>Thu, 27 Jan 2005 17:28:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-command/m-p/4882579#M846520</guid>
      <dc:creator>Victor Fridyev</dc:creator>
      <dc:date>2005-01-27T17:28:30Z</dc:date>
    </item>
    <item>
      <title>Re: grep command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-command/m-p/4882580#M846521</link>
      <description>One line perl-&lt;BR /&gt; &lt;BR /&gt;perl -n -e 'print "$1 $2 $3\n" if /(\*S+)\s+(connect)\s+(\S*)/i' text.txt&lt;BR /&gt; &lt;BR /&gt;HTH&lt;BR /&gt; &lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Thu, 27 Jan 2005 18:08:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-command/m-p/4882580#M846521</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2005-01-27T18:08:40Z</dc:date>
    </item>
    <item>
      <title>Re: grep command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-command/m-p/4882581#M846522</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;I am ussuming you just want matches for the word connect and not words that is like reconnect or connection.&lt;BR /&gt;&lt;BR /&gt;grep " connect " file.txt&lt;BR /&gt;&lt;BR /&gt;That should do the trick&lt;BR /&gt;&lt;BR /&gt;Hope this is what you want&lt;BR /&gt;&lt;BR /&gt;Gerhard</description>
      <pubDate>Fri, 28 Jan 2005 02:44:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-command/m-p/4882581#M846522</guid>
      <dc:creator>Gerhard Roets</dc:creator>
      <dc:date>2005-01-28T02:44:29Z</dc:date>
    </item>
    <item>
      <title>Re: grep command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-command/m-p/4882582#M846523</link>
      <description>I found the solution. Thanks for the sugestions.</description>
      <pubDate>Fri, 28 Jan 2005 18:02:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-command/m-p/4882582#M846523</guid>
      <dc:creator>Ridzuan Zakaria</dc:creator>
      <dc:date>2005-01-28T18:02:56Z</dc:date>
    </item>
  </channel>
</rss>

