<?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: extract a special string sequence in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/extract-a-special-string-sequence/m-p/5171253#M458084</link>
    <description>Hi,&lt;BR /&gt;&lt;BR /&gt;James your hint does't works.&lt;BR /&gt;&lt;BR /&gt;An example, I have this entries inside a file:&lt;BR /&gt;admjmm:*:124:120::/home/admjmm:/sbin/sh&lt;BR /&gt;testv201:*:136:124::/wh/leuv2:/usr/bin/ksh&lt;BR /&gt;ftp4kel:*:151:124::/wh/kel/./:/usr/bin/ftponly&lt;BR /&gt;&lt;BR /&gt;I just need extract the first one:&lt;BR /&gt;admjmm:*:124:120::/home/admjmm:/sbin/sh&lt;BR /&gt;&lt;BR /&gt;Rgds,</description>
    <pubDate>Thu, 23 Apr 2009 11:12:59 GMT</pubDate>
    <dc:creator>Jose Mosquera</dc:creator>
    <dc:date>2009-04-23T11:12:59Z</dc:date>
    <item>
      <title>extract a special string sequence</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/extract-a-special-string-sequence/m-p/5171248#M458079</link>
      <description>Hi all,&lt;BR /&gt;&lt;BR /&gt;I need extract this string sequence from a file:&lt;BR /&gt;:124:&lt;NUMERIC_FIELD&gt;:&lt;BR /&gt;&lt;BR /&gt;Where:&lt;BR /&gt;1.- Characters ":" will be assumed as field separator.&lt;BR /&gt;2.- &lt;NUMERIC_FIELD&gt; have variable lenght.&lt;BR /&gt;3.- This string sequence begins at any column position inside the file.&lt;BR /&gt;&lt;BR /&gt;Please try use grep command for this.&lt;BR /&gt;&lt;BR /&gt;Rgds.&lt;/NUMERIC_FIELD&gt;&lt;/NUMERIC_FIELD&gt;</description>
      <pubDate>Thu, 23 Apr 2009 10:39:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/extract-a-special-string-sequence/m-p/5171248#M458079</guid>
      <dc:creator>Jose Mosquera</dc:creator>
      <dc:date>2009-04-23T10:39:53Z</dc:date>
    </item>
    <item>
      <title>Re: extract a special string sequence</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/extract-a-special-string-sequence/m-p/5171249#M458080</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Please post example data and requireed o/p.&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;Ravi.</description>
      <pubDate>Thu, 23 Apr 2009 10:55:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/extract-a-special-string-sequence/m-p/5171249#M458080</guid>
      <dc:creator>G V R Shankar</dc:creator>
      <dc:date>2009-04-23T10:55:23Z</dc:date>
    </item>
    <item>
      <title>Re: extract a special string sequence</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/extract-a-special-string-sequence/m-p/5171250#M458081</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;Perhaps:&lt;BR /&gt;&lt;BR /&gt;# grep ":124:[0-9]*:" file&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 23 Apr 2009 10:57:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/extract-a-special-string-sequence/m-p/5171250#M458081</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-04-23T10:57:49Z</dc:date>
    </item>
    <item>
      <title>Re: extract a special string sequence</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/extract-a-special-string-sequence/m-p/5171251#M458082</link>
      <description>Why must it be "grep", as "sed" might be more suitable for the job?&lt;BR /&gt;&lt;BR /&gt;Off the top of my head:&lt;BR /&gt;&lt;BR /&gt;sed -ne 's/^.*:124:\([0-9]*\):.*$/\1/gp' &lt;INPUTFILE.TXT&gt;&lt;/INPUTFILE.TXT&gt;&lt;BR /&gt;This monstrous regexp might be more understandable when broken into parts:&lt;BR /&gt;&lt;BR /&gt;s/something/other/gp&lt;BR /&gt;Replaces every instance of "something" with "other", and printing the output only if we found something to replace. We are using it a bit creatively here to replace an entire line with a little bit picked from the middle of the line.&lt;BR /&gt;&lt;BR /&gt;^.*:124:\[0-9]*\):.*$&lt;BR /&gt;&lt;BR /&gt;This defines what we're looking for.&lt;BR /&gt;^  = starting from the beginning of the line&lt;BR /&gt;.* = here can be any number of any characters&lt;BR /&gt;:124: = the first string to match&lt;BR /&gt;\( = signals the beginning of the interesting part...&lt;BR /&gt;[0-9]* = ...which contains a variable number of digits and nothing else...&lt;BR /&gt;\) = then the interesting part ends.&lt;BR /&gt;:  = there must be one colon immediately after the interesting  part&lt;BR /&gt;.* = then again any number of any characters...&lt;BR /&gt;$  = until the end of the line.&lt;BR /&gt;&lt;BR /&gt;The replacement string will be simply:&lt;BR /&gt;\1 = the first (and in this case, only) interesting part indicated in the search string.&lt;BR /&gt;&lt;BR /&gt;MK</description>
      <pubDate>Thu, 23 Apr 2009 11:08:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/extract-a-special-string-sequence/m-p/5171251#M458082</guid>
      <dc:creator>Matti_Kurkela</dc:creator>
      <dc:date>2009-04-23T11:08:35Z</dc:date>
    </item>
    <item>
      <title>Re: extract a special string sequence</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/extract-a-special-string-sequence/m-p/5171252#M458083</link>
      <description>Oops, I assumed you'd want only the content of the numeric field. If you want the entire&lt;BR /&gt;:123:&lt;NUMERIC_FIELD&gt;:, then:&lt;BR /&gt;&lt;BR /&gt;sed -ne 's/^.*\(:124:[0-9]*:\).*$/\1/gp' &lt;INPUTFILE.TXT&gt;&lt;/INPUTFILE.TXT&gt;&lt;BR /&gt;I.e. just move the "start &amp;amp; end of the interesting part" indicators to the correct spot.&lt;BR /&gt;&lt;BR /&gt;MK&lt;/NUMERIC_FIELD&gt;</description>
      <pubDate>Thu, 23 Apr 2009 11:12:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/extract-a-special-string-sequence/m-p/5171252#M458083</guid>
      <dc:creator>Matti_Kurkela</dc:creator>
      <dc:date>2009-04-23T11:12:58Z</dc:date>
    </item>
    <item>
      <title>Re: extract a special string sequence</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/extract-a-special-string-sequence/m-p/5171253#M458084</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;James your hint does't works.&lt;BR /&gt;&lt;BR /&gt;An example, I have this entries inside a file:&lt;BR /&gt;admjmm:*:124:120::/home/admjmm:/sbin/sh&lt;BR /&gt;testv201:*:136:124::/wh/leuv2:/usr/bin/ksh&lt;BR /&gt;ftp4kel:*:151:124::/wh/kel/./:/usr/bin/ftponly&lt;BR /&gt;&lt;BR /&gt;I just need extract the first one:&lt;BR /&gt;admjmm:*:124:120::/home/admjmm:/sbin/sh&lt;BR /&gt;&lt;BR /&gt;Rgds,</description>
      <pubDate>Thu, 23 Apr 2009 11:12:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/extract-a-special-string-sequence/m-p/5171253#M458084</guid>
      <dc:creator>Jose Mosquera</dc:creator>
      <dc:date>2009-04-23T11:12:59Z</dc:date>
    </item>
    <item>
      <title>Re: extract a special string sequence</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/extract-a-special-string-sequence/m-p/5171254#M458085</link>
      <description>If you are parsing a Unix /etc/passwd file, then you can use "cut" with a much simpler syntax:&lt;BR /&gt;&lt;BR /&gt;cut -d : -f 3-4 &amp;lt; /etc/passwd | grep "124:"&lt;BR /&gt;&lt;BR /&gt;The cut command gives fields 3 and 4 of the password file (UID and primary GID) alone, then you can use grep to pick the line you want.&lt;BR /&gt;&lt;BR /&gt;MK</description>
      <pubDate>Thu, 23 Apr 2009 11:19:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/extract-a-special-string-sequence/m-p/5171254#M458085</guid>
      <dc:creator>Matti_Kurkela</dc:creator>
      <dc:date>2009-04-23T11:19:06Z</dc:date>
    </item>
    <item>
      <title>Re: extract a special string sequence</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/extract-a-special-string-sequence/m-p/5171255#M458086</link>
      <description>If you have a variable position for your numeric_field this is hard to extract without using a regexp. If you know that lets say the 3 column (with colon as delimiter) is the number you want something like this could be used:&lt;BR /&gt;&lt;BR /&gt;grep ":124:" file.txt | cut -d':' -f3&lt;BR /&gt;&lt;BR /&gt;If you don't know the regexp in the previous post should be more efficient find it.&lt;BR /&gt;&lt;BR /&gt;grep ":124:" | sed "s/^.*:124:\([^:]\+\).*$/\1/"&lt;BR /&gt;&lt;BR /&gt;[^:]\+ is just a better way of stopping at the first colon then using ".*".&lt;BR /&gt;[^:]\+ tells sed to search from the position it's initiated from until it runs into a character matching the one behind circumflex (^).&lt;BR /&gt;&lt;BR /&gt;Best regards&lt;BR /&gt;Fredrik Eriksson&lt;BR /&gt;</description>
      <pubDate>Thu, 23 Apr 2009 11:20:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/extract-a-special-string-sequence/m-p/5171255#M458086</guid>
      <dc:creator>Fredrik.eriksson</dc:creator>
      <dc:date>2009-04-23T11:20:15Z</dc:date>
    </item>
    <item>
      <title>Re: extract a special string sequence</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/extract-a-special-string-sequence/m-p/5171256#M458087</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;# grep -E :124:[0-9]+: file&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 23 Apr 2009 11:26:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/extract-a-special-string-sequence/m-p/5171256#M458087</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-04-23T11:26:28Z</dc:date>
    </item>
    <item>
      <title>Re: extract a special string sequence</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/extract-a-special-string-sequence/m-p/5171257#M458088</link>
      <description>Matti, good and easy way to do this!&lt;BR /&gt;THX a lot to everybody for you sooner answers.</description>
      <pubDate>Thu, 23 Apr 2009 14:10:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/extract-a-special-string-sequence/m-p/5171257#M458088</guid>
      <dc:creator>Jose Mosquera</dc:creator>
      <dc:date>2009-04-23T14:10:43Z</dc:date>
    </item>
  </channel>
</rss>

