Check Sequence


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Check Sequence
# 1  
Old 12-14-2011
Check Sequence

*
Expiry DATE:
*
Address1:
Address2:
Address3:
Address4:
Address5:
*
PO_ref_number: aadad
HolderId_1:
HolderId_2:
HolderId_3:
HolderId_4:
*
adad: 00000
ada: 00000
adad: RANDOM
adad: RANDOM
******************************
* INPUT VARIABLES
******************************
adad:
ada: 621300020985821
ada: 8923401000117943621
ada: 0117943621
******************************
* Oadada
******************************
adad: ada/ada/ada/adad/ada
621300020985821 89234010001179436212 0002 79800474 36831269 F1D86C67 1D84E3FEA7BF3CFB8439A331DC2FC64A
621300020985822 89234010001179436220 0004 74291278 27393700 33BAF502 DA8EA7D6EA2675250E7E23F37CBBE64D


Hi,

I have file as above. I need to check if there is a way to check if the ones in bold are in sequence. the file may contain upto 5000 records and I need to check for sequence for only ones in bold. Please help. (If I can have an answer in awk it will be great since arrays in perl will have performance related issues)

Thanks,
Arun
# 2  
Old 12-14-2011
What have you tried so far?
# 3  
Old 12-14-2011
Currently I have 2 functions, one to check if the elements are in sequence and the other to get only those part of the file that needs to be checked for sequence

1) Cut only the columns of file that needs sequence checking (I have attached file. I wrote the function in Editplus for indentation)
2) to check if the elements are in sequence as below :

Code:
sub is_increasing_array {
    return unless @_;
    return 1 if @_ == 1;

    foreach (1 .. $#_) {
        if ($_[$_] != $_[$_ - 1] + 1)    {
            return ($_[$_] , $_[$_ - 1]);
        }

    return 1;
}

I have to mention that there are two hash maps which are used. one contains the start value from where the sequence validation needs to be performed and other has the name of the files on which validation has to be performed.

In the files the position of the columns on which it has to be performed may change. I have handled that part. I actually needed to know if we can use awk to check for sequence Or a Regex for the same (I did not ask this before)

Please advise

Thanks

Last edited by radoulov; 12-14-2011 at 12:57 PM.. Reason: Code tags!
# 4  
Old 12-14-2011
Sorry, I gave a wrong solution. My mistake. Apologies.

Last edited by balajesuri; 12-14-2011 at 07:23 AM..
# 5  
Old 12-15-2011
OK,
I'll need more information.
Could you please post a bigger sample of your input? I need to know if you're interested in all the records (untill the end of the file) after the line containing adad: ada/ada/ada/adad/ada.

And the numbers to be verified are:

Code:
621300020985821
621300020985822
...

and

Code:
89234010001179436212
89234010001179436220
...

?

I.e. the first one is OK, the second not?
What should happen if the numbers are not in sequence?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

To check the missing file based on sequence number.

Hi All, I have a requirement that i need to list only the missing sequences with a unix script. For Example: Input: FILE_001.txt FILE_002.txt FILE_005.txt FILE_006.txt FILE_008.txt FILE_009.txt FILE_010.txt FILE_014.txt Output: FILE_003.txt FILE_004.txt FILE_007.txt FILE_011.txt... (5 Replies)
Discussion started by: Arun1992
5 Replies

2. Red Hat

Rm -rf * sequence

If I run rm -rf * command under one parent directory. /data > rm -rf * Is there anyway to know which files will be deleted first ? Start using code tags please, ty. (2 Replies)
Discussion started by: sameermohite
2 Replies

3. Shell Programming and Scripting

How to check missing sequence?

I want to listed files every hours and check the missing sequence my file format is CV.020220131430.txt CV.020220131440.txt CV.020220131450.txt CV.ddmmyyhhm.txt how to check if i have missing files in sequence .. thanks (3 Replies)
Discussion started by: before4
3 Replies

4. Shell Programming and Scripting

find common entries and match the number with long sequence and cut that sequence in output

Hi all, I have a file like this ID 3BP5L_HUMAN Reviewed; 393 AA. AC Q7L8J4; Q96FI5; Q9BQH8; Q9C0E3; DT 05-FEB-2008, integrated into UniProtKB/Swiss-Prot. DT 05-JUL-2004, sequence version 1. DT 05-SEP-2012, entry version 71. FT COILED 59 140 ... (1 Reply)
Discussion started by: manigrover
1 Replies

5. OS X (Apple)

Check file sequence script not working. Need help.

I have a script to check a file sequence for missing frames. It used to work in true Unix but now on OSX 10.6.4 (bash) it reports every frame is missing. Hopefully someone here can help. #!/bin/csh -f if ($#argv < 1) then echo echo "Usage: checkseq <name> " echo... (3 Replies)
Discussion started by: scribling
3 Replies

6. Shell Programming and Scripting

ID generation in sequence

i have an xml tag. The value for the tag should be iterated through out the xml document. eg: <data><id><id><name>a</name><addr>aaa</addr><phnumb>3456</phnumb><state>ca</state><city>ny</city></data>... (6 Replies)
Discussion started by: Sgiri1
6 Replies

7. Shell Programming and Scripting

To grep in sequence

Hi, I have a log file containg records in sequence <CRMSUB:MSIN=2200380,BSNBC=TELEPHON-7553&TS21-7716553&TS22-7716553,NDC=70,MSCAT=ORDINSUB,SUBRES=ONAOFPLM,ACCSUB=BSS,NUMTYP=SINGLE; <ENTROPRSERV:MSIN=226380,OPRSERV=OCSI-PPSMOC-ACT-DACT&TCSI-PPSMTC-ACT-DACT&UCSI-USSD;... (17 Replies)
Discussion started by: helplineinc
17 Replies

8. Shell Programming and Scripting

Script to check file sequence

Hi everyone, I need help in creating a script that would check if the file sequence is in order in a particular directory. These are log files that are generated throughout the day. Example of the file name will be, ABC01_YYMMDDHHMM###### (ABC01_0904161829000001) Sometimes the file... (4 Replies)
Discussion started by: kumaran21
4 Replies

9. Shell Programming and Scripting

help - script can check jump sequence?

Hi, if I have a lot of files like (AABBCC0010, AABBCC0011, AABBCC0012....AABBCC1000), can I write a small script to check any sequence number jump and show me the result which sequence number? #The first sequence may start from 0010 or 0101... :confused: Thank you!! (10 Replies)
Discussion started by: happyv
10 Replies

10. Solaris

STOP A sequence

Hi, I have a sun sparc system. I don't have a sun keyboard, hence i connected a pc keyboard. I would like to know the "STOP A" equivalent command to be used on pc keyboard. Regards, Raja (4 Replies)
Discussion started by: RajaRC
4 Replies
Login or Register to Ask a Question