help - script can check jump sequence?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting help - script can check jump sequence?
# 1  
Old 09-19-2006
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... Smilie

Thank you!!
# 2  
Old 09-20-2006
You can write a small script to do that. Here is one that I wrote:

Code:
#!/bin/sh
start=1

for file_number in  `ls -1 AABBCC* | sort | cut -c 7,8,9,10`
do
    if [ $start = 1 ] ; then
    # this is the first pass of the loop, so we've got nothing to compare
        start=0
    else
    # this is not the first pass of the loop
        previous=`expr $previous + 1`
        echo "comparing $file_number and $previous ... "
        if [ $file_number = $previous ] ; then
            echo "file names are in sequence "
        else
            echo "file names $file_number are not in sequence "
        fi
    fi
    previous=$file_number
done

I assumed that filenames are AABBCCxxxx where xxxx is a number, which is of interest to us. Please note that this script does not work with smaller numbers, of 3 digits and 2 digits. Reason is that expr strips the leading zeros in such numbers (0010 becomes 10 which then breaks the sequence)

Last edited by Yogesh Sawant; 08-28-2009 at 05:29 AM.. Reason: added code tags
# 3  
Old 09-20-2006
not work..
when I run the script, it showing the error below:

Code:
expr: non-numeric argument
comparing SIMAC and  ... 
ksh: test: argument expected
file names SIMAC are not in sequence 
expr: non-numeric argument
comparing SIMAC and  ... 
ksh: test: argument expected
file names SIMAC are not in sequence 
expr: non-numeric argument


Last edited by Yogesh Sawant; 08-28-2009 at 05:30 AM.. Reason: added code tags
# 4  
Old 09-20-2006
if [ $start = 1 ] replace with if [ $start -eq 1 ]
and if [ $file_number = $previous ] with if [ $file_number -eq $previous ]
# 5  
Old 09-20-2006
You are using ksh to execute this script. Try using sh. Run it as:

$ sh scriptname

where scriptname is the name of the script
# 6  
Old 09-20-2006
I try to run:

sh checkseq (scriptname)

it showing:
Code:
expr: non-numeric argument
comparing SIMAC and  ... 
checkseq: test: argument expected


Last edited by Yogesh Sawant; 08-28-2009 at 05:31 AM.. Reason: added code tags
# 7  
Old 09-20-2006
The variable previous is not initialised.
Modify the script :
Code:
if [ $start -eq 1 ] ; then
   # this is the first pass of the loop, so we've got nothing to compare
   start=0
   previous=$file_number
else


Jean-Pierre.
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. Shell Programming and Scripting

Notify when the script run(hourly)on my jump-box only when there is a failure on my remote-box

Team, Presently I have a script, which i have set up cron on one of my Jump-boxes,and gives me the output on every hourly basis,fetching the data from the remote machine.Basically it gives me the list of all active users logged and its count once we execute the script.Here the count is... (6 Replies)
Discussion started by: whizkidash
6 Replies

3. Shell Programming and Scripting

[Solved] How to make the script jump to sleep?

Hi Gurus, I am working one below script. I am stuck at the else condition. #!/bin/ksh while : do cur_date=`date |cut -d"," -f 1` cur_time=`date +"%H%M" if ||; then if && ; then echo "File " $FIRST_FILE "... (8 Replies)
Discussion started by: ken6503
8 Replies

4. 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

5. 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

6. Shell Programming and Scripting

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 ****************************** (4 Replies)
Discussion started by: arunshankar.c
4 Replies

7. 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

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

checking jump sequence number (part2)

The following script have some bug...can you all help me: #!/bin/sh start=1 for file_number in `ls -1 /appl/CH_DATA/archive/list1/CACHE/CDBACKUPFILEJohn*.archived | sort | cut -c 48,49,50,51` do if ; then # this is the first pass of the loop, so we've got nothing to compare start=0... (3 Replies)
Discussion started by: happyv
3 Replies

10. UNIX for Dummies Questions & Answers

Script in boot sequence

Hi , I have some problems with my library when the sytem boot : When HPUX is booting, HPUX and STAPE claim the drive initially. HPUX assigns an instance number. The instance number is tied to the hardware path. Near the end of the boot, the ATDD driver claims the drive from STAPE based... (1 Reply)
Discussion started by: delphine
1 Replies
Login or Register to Ask a Question