Finding repitition of series


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Finding repitition of series
# 1  
Old 09-29-2011
MySQL Finding repitition of series

Dear friends,
hello to everyone. I am new to this forum.
I have a set of data where I need to find the repitition of series as below

data format:
0001230000456000001230000456
each digit can be separated by any delimeter

I need to find out the starting point (index) of '123' and '456'

I need to find out the 2 kinds of series and their index

I think I have explained my problem.

Please solve this for me.
# 2  
Old 09-29-2011
Code:
awk 'function find(val)
      {
        p=$0
        while( (inx=index(p,val))>0 )
        {
           print val, inx
           p=substr(p,inx+1)
        }
     }
     /123/ {find("123") }
     /456/ {find("456") } 
     '   filename

# 3  
Old 09-30-2011
Code:
echo "123 index"
sed -n 's/123/\n/gp' 1|awk 'BEGIN{i=1}{i+=length($0);a[NR]=i;i+=3}END{for(i in a){print a[i]}}'|sort -n
echo "456 index"
sed -n 's/456/\n/gp' 1|awk 'BEGIN{i=1}{i+=length($0);a[NR]=i;i+=3}END{for(i in a){print a[i]}}'|sort -n


Last edited by Scott; 09-30-2011 at 05:36 AM.. Reason: Code tags, please.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Red Hat

Find the series

Hai what command is used to find red hat linux 5 series? (2 Replies)
Discussion started by: vinayd
2 Replies

2. Shell Programming and Scripting

SED: Pattern repitition regex matching

Fairly straightforward, but I'm having an awful time getting what I thought was a simple regex to work. I'll give the command I was playing with, and I'm aware why this one doesn't work (the 1,3 is off the A-Z, not the whole expression), I just don't know what the fix is: Actual Output(s): $... (5 Replies)
Discussion started by: Vryali
5 Replies

3. Shell Programming and Scripting

Finding Minimum in a Series

I have two LARGE files of data more than 20,000 line each, file-1 and file-2, and I wish to do the following if possible: file-1 1 2 5 7 9 2 4 6 3 8 9 4 6 8 9 3 2 1 3 1 2 . . . file-2 1 2 3 2 5 7 5 7 3 7 9 4 . (5 Replies)
Discussion started by: ali2011
5 Replies

4. UNIX for Dummies Questions & Answers

Finding specific series of strings or characters

After spending sometime playing around with my script I just cannot get it to do what I want. So I decided to ask. My file looks something like this: I am using the following code to extract sequences that contain dashes awk '/^>/{id=$0;next}{if (match($1,"-")) print id "\n" $0}' infile ... (17 Replies)
Discussion started by: Xterra
17 Replies

5. Solaris

M Series

Hi All, Do anyone know if I upgrade cpu module and memory module for one of the domain inside Sun M5000. After the upgrade, will the hostid for the domain change or it will remain as long we don't change the system board? Currently will try to upgrade one of the Sun M5000 with 4 domains... (2 Replies)
Discussion started by: mailbox80
2 Replies

6. Programming

series of combinations

HI I have a series(sorted), which i require to create combinations. I am not getting the good code for doing this. My series should generate the following combinations... Please help me in getting this in C++. Thanks for your help. A: A A B: A B A B A B C: A ... (1 Reply)
Discussion started by: rameshmelam
1 Replies

7. Programming

C with MQ Series

Hi, Any one please let me know, how to write in to MQ Series through C. I tried, but it was vein, am expecting material(URL) or code. Thanks, Naga:cool: (5 Replies)
Discussion started by: Nagapandi
5 Replies

8. Shell Programming and Scripting

finding duplicate files by size and finding pattern matching and its count

Hi, I have a challenging task,in which i have to find the duplicate files by its name and size,then i need to take anyone of the file.Then i need to open the file and find for more than one pattern and count of that pattern. Note:These are the samples of two files,but i can have more... (2 Replies)
Discussion started by: jerome Sukumar
2 Replies

9. Shell Programming and Scripting

Fibonacci series

Need code to run the Fibonacci series from 0 to 10 (16 Replies)
Discussion started by: nycol
16 Replies

10. Programming

Ibm Mq Series

hi everybody, My name is Raj i work in GE Global Software Solutions As Siebel Analyst. Can any one help in writing the code in Ansi C on HP-Unix platform to get data from IBM MQ-Series Server. IBM MQ-series client will be installed on the client machine which is on WIN NT platform. And MQ-series... (2 Replies)
Discussion started by: garimella
2 Replies
Login or Register to Ask a Question