Operating System - HP-UX
1752277 Members
4599 Online
108786 Solutions
New Discussion юеВ

Re: shell script - for loop statement

 
SOLVED
Go to solution
amonamon
Regular Advisor

Re: shell script - for loop statement

well...:( no perl becouse I do not have experience with it..and I do not have it installed..

also haw to match numbers taht are incremented?

like

0123
5678
3456
4567
1111
0011
9999

result should be:

0123
5678
3456
4567

so far I tryed this: please do not laugh..:)

grep "\([0-9]\)\(\1+1)\(\1+2)\(\1+3)" tmp

thanks.
Ollie Rowland
Frequent Advisor

Re: shell script - for loop statement

Hi,

I know you don't want perl, but here goes anyway:

#!/usr/contrib/bin/perl

while () {
($a, $b, $c, $d) = /(.)(.)(.)(.)/;
print $_ if ($_ =~ /^$a$b$c$d$/ and $b == $a+1
and $c == $b+1
and $d == $c+1 );
}
Hemmetter
Esteemed Contributor

Re: shell script - for loop statement

hi,

since all ascending 4 digit sequences are:
"0123|1234|2345|3456|4567|5678|6789"

it ist a simple grep statement:
$ egrep "0123|1234|2345|3456|4567|5678|6789" tmp


rgds
HGH
Ollie Rowland
Frequent Advisor

Re: shell script - for loop statement

Hi,

Thanks Hemmetter, I've also learned lots with this thread.

It's a shame I can't assign points to you for this......!