<?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: shell script - for loop statement in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-for-loop-statement/m-p/4266381#M674587</link>
    <description>Hi again,&lt;BR /&gt;&lt;BR /&gt;it is as easy as:&lt;BR /&gt;&lt;BR /&gt;$ grep  "\([0-9]\)\1\([0-9]\)\2" tmp | grep -v "\([0-9]\)\1\1\1"&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Rgds&lt;BR /&gt;HGH&lt;BR /&gt;</description>
    <pubDate>Wed, 10 Sep 2008 11:06:13 GMT</pubDate>
    <dc:creator>Hemmetter</dc:creator>
    <dc:date>2008-09-10T11:06:13Z</dc:date>
    <item>
      <title>shell script - for loop statement</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-for-loop-statement/m-p/4266374#M674580</link>
      <description>Hello&lt;BR /&gt;&lt;BR /&gt;I have file:&lt;BR /&gt;&lt;BR /&gt;0011&lt;BR /&gt;5566&lt;BR /&gt;1265&lt;BR /&gt;7889&lt;BR /&gt;7878&lt;BR /&gt;&lt;BR /&gt;I should match pattern aabb so that output could be:&lt;BR /&gt;&lt;BR /&gt;0011&lt;BR /&gt;5566&lt;BR /&gt;&lt;BR /&gt;so far I did this:&lt;BR /&gt;&lt;BR /&gt;set -A arr `echo "0:1:2:3:4:5:6:7:8:9" | nawk -F":" '{for(i=1;i&amp;lt;=NF;i++) print $i}'`&lt;BR /&gt;for num in ${arr[@]}&lt;BR /&gt;do&lt;BR /&gt;                &lt;BR /&gt;&lt;BR /&gt;grep $num$num00 tmp&lt;BR /&gt;grep $num$num11 tmp&lt;BR /&gt;grep $num$num22 tmp&lt;BR /&gt;grep $num$num33 tmp&lt;BR /&gt;grep $num$num44 tmp&lt;BR /&gt;grep $num$num55 tmp&lt;BR /&gt;grep $num$num66 tmp&lt;BR /&gt;grep $num$num77 tmp&lt;BR /&gt;grep $num$num88 tmp&lt;BR /&gt;grep $num$num99 tmp&lt;BR /&gt;                                       &lt;BR /&gt;&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;is there more effective way?</description>
      <pubDate>Wed, 10 Sep 2008 09:11:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-for-loop-statement/m-p/4266374#M674580</guid>
      <dc:creator>amonamon</dc:creator>
      <dc:date>2008-09-10T09:11:03Z</dc:date>
    </item>
    <item>
      <title>Re: shell script - for loop statement</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-for-loop-statement/m-p/4266375#M674581</link>
      <description>it could be nice if possible to have another for statement inside this one to loop from 0 - 9</description>
      <pubDate>Wed, 10 Sep 2008 09:14:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-for-loop-statement/m-p/4266375#M674581</guid>
      <dc:creator>amonamon</dc:creator>
      <dc:date>2008-09-10T09:14:09Z</dc:date>
    </item>
    <item>
      <title>Re: shell script - for loop statement</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-for-loop-statement/m-p/4266376#M674582</link>
      <description>again me&lt;BR /&gt;also I tryed this one..&lt;BR /&gt;&lt;BR /&gt;#!/bin/ksh&lt;BR /&gt;&lt;BR /&gt;k=0&lt;BR /&gt;l=0&lt;BR /&gt;&lt;BR /&gt;while [ $k -lt 10 ]; do&lt;BR /&gt;&lt;BR /&gt;   while [ $l -lt 10 ]; do&lt;BR /&gt;        grep $k$k$l$l tmp&lt;BR /&gt;     l=`expr $l + 1`&lt;BR /&gt;   done&lt;BR /&gt;&lt;BR /&gt; k=`expr $k + 1`&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;again stupid result..</description>
      <pubDate>Wed, 10 Sep 2008 09:25:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-for-loop-statement/m-p/4266376#M674582</guid>
      <dc:creator>amonamon</dc:creator>
      <dc:date>2008-09-10T09:25:43Z</dc:date>
    </item>
    <item>
      <title>Re: shell script - for loop statement</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-for-loop-statement/m-p/4266377#M674583</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;try this one:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;$ grep  "\([0-9]\)\1\([0-9]\)\2" file&lt;BR /&gt;&lt;BR /&gt;and see regexp(5)&lt;BR /&gt;&lt;BR /&gt;rgds&lt;BR /&gt;HGH&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 10 Sep 2008 09:58:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-for-loop-statement/m-p/4266377#M674583</guid>
      <dc:creator>Hemmetter</dc:creator>
      <dc:date>2008-09-10T09:58:57Z</dc:date>
    </item>
    <item>
      <title>Re: shell script - for loop statement</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-for-loop-statement/m-p/4266378#M674584</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Or you could use perl...&lt;BR /&gt;&lt;BR /&gt;Create the script match.pl&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;while (&lt;STDIN&gt;) {&lt;BR /&gt;   ($a, $b) = /(.).(.)./;&lt;BR /&gt;   print $_ if ($_ =~ /$a$a$b$b/);&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;and put your numbers in match.txt&lt;BR /&gt;&lt;BR /&gt;Execute with&lt;BR /&gt;&lt;BR /&gt;cat match.txt | match.pl&lt;BR /&gt;&lt;BR /&gt;Don't forget to make your match.pl executable!&lt;/STDIN&gt;</description>
      <pubDate>Wed, 10 Sep 2008 10:13:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-for-loop-statement/m-p/4266378#M674584</guid>
      <dc:creator>Ollie Rowland</dc:creator>
      <dc:date>2008-09-10T10:13:26Z</dc:date>
    </item>
    <item>
      <title>Re: shell script - for loop statement</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-for-loop-statement/m-p/4266379#M674585</link>
      <description>no perl pleasee..&lt;BR /&gt;&lt;BR /&gt;Hemmetter that was nice..but also with this grep numbers 7777 and 3333 and 1111 etc. are also colected..but they should not be taken.</description>
      <pubDate>Wed, 10 Sep 2008 10:40:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-for-loop-statement/m-p/4266379#M674585</guid>
      <dc:creator>amonamon</dc:creator>
      <dc:date>2008-09-10T10:40:19Z</dc:date>
    </item>
    <item>
      <title>Re: shell script - for loop statement</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-for-loop-statement/m-p/4266380#M674586</link>
      <description>#!/usr/contrib/bin/perl&lt;BR /&gt;&lt;BR /&gt;while (&lt;STDIN&gt;) {&lt;BR /&gt;   ($a, $b) = /(.).(.)./;&lt;BR /&gt;   print $_ if ($_ =~ /$a$a$b$b/ and $a != $b);&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;lt;&amp;lt;&amp;lt; GRIN &amp;gt;&amp;gt;&amp;gt;&lt;/STDIN&gt;</description>
      <pubDate>Wed, 10 Sep 2008 10:46:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-for-loop-statement/m-p/4266380#M674586</guid>
      <dc:creator>Ollie Rowland</dc:creator>
      <dc:date>2008-09-10T10:46:09Z</dc:date>
    </item>
    <item>
      <title>Re: shell script - for loop statement</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-for-loop-statement/m-p/4266381#M674587</link>
      <description>Hi again,&lt;BR /&gt;&lt;BR /&gt;it is as easy as:&lt;BR /&gt;&lt;BR /&gt;$ grep  "\([0-9]\)\1\([0-9]\)\2" tmp | grep -v "\([0-9]\)\1\1\1"&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Rgds&lt;BR /&gt;HGH&lt;BR /&gt;</description>
      <pubDate>Wed, 10 Sep 2008 11:06:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-for-loop-statement/m-p/4266381#M674587</guid>
      <dc:creator>Hemmetter</dc:creator>
      <dc:date>2008-09-10T11:06:13Z</dc:date>
    </item>
    <item>
      <title>Re: shell script - for loop statement</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-for-loop-statement/m-p/4266382#M674588</link>
      <description>nice..I would never come up with that easy line..&lt;BR /&gt;&lt;BR /&gt;thanks</description>
      <pubDate>Wed, 10 Sep 2008 11:18:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-for-loop-statement/m-p/4266382#M674588</guid>
      <dc:creator>amonamon</dc:creator>
      <dc:date>2008-09-10T11:18:36Z</dc:date>
    </item>
    <item>
      <title>Re: shell script - for loop statement</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-for-loop-statement/m-p/4266383#M674589</link>
      <description>Hi Amonamon:&lt;BR /&gt;&lt;BR /&gt;&amp;gt; no perl please...&lt;BR /&gt;&lt;BR /&gt;Why?  Perl runs on virtually any kind of platform you can find --- that "other" operating system, too.&lt;BR /&gt;&lt;BR /&gt;A shell script can just as easily run a Perl snippet as it can a 'grep' process.&lt;BR /&gt;&lt;BR /&gt;All that aside, here's a regular expression in Perl (using negative look-ahead) to do your job:&lt;BR /&gt;&lt;BR /&gt;# X="0011\n5566\n1265\n7889\n7878" #...your data&lt;BR /&gt;&lt;BR /&gt;# echo ${X} | perl -ne 'print if m{ ((^\d)\2) (?!\2) }x'&lt;BR /&gt;0011&lt;BR /&gt;5566&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;</description>
      <pubDate>Wed, 10 Sep 2008 16:05:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-for-loop-statement/m-p/4266383#M674589</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2008-09-10T16:05:32Z</dc:date>
    </item>
    <item>
      <title>Re: shell script - for loop statement</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-for-loop-statement/m-p/4266384#M674590</link>
      <description>well...:( no perl becouse I do not have experience with it..and I do not have it installed..&lt;BR /&gt;&lt;BR /&gt;also haw to match numbers taht are incremented?&lt;BR /&gt;&lt;BR /&gt;like&lt;BR /&gt;&lt;BR /&gt;0123&lt;BR /&gt;5678&lt;BR /&gt;3456&lt;BR /&gt;4567&lt;BR /&gt;1111&lt;BR /&gt;0011&lt;BR /&gt;9999&lt;BR /&gt;&lt;BR /&gt;result should be:&lt;BR /&gt;&lt;BR /&gt;0123&lt;BR /&gt;5678&lt;BR /&gt;3456&lt;BR /&gt;4567&lt;BR /&gt;&lt;BR /&gt;so far I tryed this: please do not laugh..:)&lt;BR /&gt;&lt;BR /&gt;grep "\([0-9]\)\(\1+1)\(\1+2)\(\1+3)" tmp&lt;BR /&gt;&lt;BR /&gt;thanks.&lt;BR /&gt;</description>
      <pubDate>Thu, 11 Sep 2008 06:58:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-for-loop-statement/m-p/4266384#M674590</guid>
      <dc:creator>amonamon</dc:creator>
      <dc:date>2008-09-11T06:58:28Z</dc:date>
    </item>
    <item>
      <title>Re: shell script - for loop statement</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-for-loop-statement/m-p/4266385#M674591</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I know you don't want perl, but here goes anyway:&lt;BR /&gt;&lt;BR /&gt;#!/usr/contrib/bin/perl&lt;BR /&gt;&lt;BR /&gt;while (&lt;STDIN&gt;) {&lt;BR /&gt;   ($a, $b, $c, $d) = /(.)(.)(.)(.)/;&lt;BR /&gt;   print $_ if ($_ =~ /^$a$b$c$d$/ and $b == $a+1&lt;BR /&gt;                                   and $c == $b+1&lt;BR /&gt;                                   and $d == $c+1 );&lt;BR /&gt;}&lt;BR /&gt;&lt;/STDIN&gt;</description>
      <pubDate>Thu, 11 Sep 2008 07:18:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-for-loop-statement/m-p/4266385#M674591</guid>
      <dc:creator>Ollie Rowland</dc:creator>
      <dc:date>2008-09-11T07:18:53Z</dc:date>
    </item>
    <item>
      <title>Re: shell script - for loop statement</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-for-loop-statement/m-p/4266386#M674592</link>
      <description>hi,&lt;BR /&gt;&lt;BR /&gt;since all ascending 4 digit sequences are:&lt;BR /&gt;"0123|1234|2345|3456|4567|5678|6789"&lt;BR /&gt;&lt;BR /&gt;it ist a simple grep statement:&lt;BR /&gt;$ egrep "0123|1234|2345|3456|4567|5678|6789" tmp&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;rgds&lt;BR /&gt;HGH&lt;BR /&gt;</description>
      <pubDate>Thu, 11 Sep 2008 07:33:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-for-loop-statement/m-p/4266386#M674592</guid>
      <dc:creator>Hemmetter</dc:creator>
      <dc:date>2008-09-11T07:33:19Z</dc:date>
    </item>
    <item>
      <title>Re: shell script - for loop statement</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-for-loop-statement/m-p/4266387#M674593</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Thanks Hemmetter, I've also learned lots with this thread.&lt;BR /&gt;&lt;BR /&gt;It's a shame I can't assign points to you for this......!</description>
      <pubDate>Thu, 11 Sep 2008 07:38:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-for-loop-statement/m-p/4266387#M674593</guid>
      <dc:creator>Ollie Rowland</dc:creator>
      <dc:date>2008-09-11T07:38:26Z</dc:date>
    </item>
  </channel>
</rss>

