How to take the missing sequence Number?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to take the missing sequence Number?
# 1  
Old 07-23-2012
How to take the missing sequence Number?

Am using unix aix KSH...
I have the files called
Code:
MMRR0106.DAT
MMRR0206.DAT
MMRR0406.DAT
MMRR0506.DAT
MMRR0806.DAT
....
...
MMRR3006.DAT
MMRR0207.DAT

These files are in one dircetory /venky ?

I want the output like this ?
Missing files are :
Code:
MMRR0306.DAT
MMRR0606.DAT
MMRR0706.DAT
MMRR0107.DAT

In this i wont want to take the files on sat and sun (ie 0306 is june 3rd so every month i wont check the files on sat and sun which is in /venky directory)

can anybody know the solutions .........
Thanks in advance ........

---------- Post updated at 02:03 AM ---------- Previous update was at 02:00 AM ----------

HOW TO TAKE MISSING FILES...

Hi ,
Am using unix aix
I want to find the missing sequence no inside the files..
for ex ..
file mmm has following contents ..(files doesnt contains any character its have only the numbers)
1
3
4
5
8
--
---

i need the results as
missing no as
2
6
7
-
-

Last edited by Ygor; 07-23-2012 at 09:24 AM.. Reason: Merged post from Homework forum.
# 2  
Old 07-23-2012
I'm really not certain if this is what you're looking for, if it's not please provide a little more info:

Code:
#!/bin/sh
start_number=1
current_number=0
errfound=0
errfiles=""


for file in $(ls /venky); do
    current_number="${start_number}"
    file_error=0
    while read line; do 
        if [ ! "${line}" = "${current_number}" ]; then
            echo "Missing number: ${current_number}"
            file_error=1
        fi  
    done < $file
    if [ "${file_error}" -ne 0 ]; then
        errfiles="${errfiles}${file} "
    fi
done
if [ ! -z "${errfiles}" ]; then
    echo "The following files are missing numbers:"
    echo "${errfiles}"
fi
exit 0

This User Gave Thanks to Vryali For This Post:
# 3  
Old 07-24-2012
Thanks for reply ,
actually i didnt get the exact answers ..
take as examples ;
we have the file as tt.sh and contents as
4
5
7
8
14
...
..
i need the output like this ..(note file contents start line not be one it may be any value )
Missing number in the files are:-
6
9
10
11
12
13
.
.
.
# 4  
Old 07-24-2012
A solution with awk:

Code:
awk 'p && p != $1 { for( i = p; i < $1; i++ ) print i; } {p = $1 + 1 }' input-file

# 5  
Old 07-24-2012
thanks agama
its working fine ..but its taking the value from 1 ..
i dont want like that..
for ex:
first line in the file is 3
then
wants missing no after first line ..
# 6  
Old 07-24-2012
May be you have to extract the number from the first line Smilie
This User Gave Thanks to PikK45 For This Post:
# 7  
Old 07-24-2012
can u tell me how to extract the first line ...
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

Find the missing sequence

Dear all i am having file with max 24 entries. i want to find which sequence is missing file is like this df00231587.dat df01231587.dat df03231587.dat df05231587.dat . . . df23231587.dat the changing seq is 00-23,so i would like to find out which seq is missing like in above... (13 Replies)
Discussion started by: sagar_1986
13 Replies

3. Shell Programming and Scripting

Identifying Missing File Sequence

Hi, I have a file which contains few columns and the first column has the file names, and I would like to identify the missing file sequence number form the file and would copy to another file. My files has data in below format. APKRISPSIN320131231201319_0983,1,54,125,... (5 Replies)
Discussion started by: rramkrishnas
5 Replies

4. Shell Programming and Scripting

Find missing sequence

Hi, I need to find out the missing sequence from a list. However the issue is there is not a fixed start and end, it depends on the generation of files. For eg, it might start with 4000 and end with 9000. Based on this, I need a script which greps the start and end sequence from the... (3 Replies)
Discussion started by: danish0909
3 Replies

5. Shell Programming and Scripting

Case script to get missing sequence among files

I want to use case statement to find the range of missing sequence in my directory which it has some few ( dat & DAT ) files my directory /home/arm/my_folder/20130428 contains : f01_201304280000.DAT f01_201304280001.DAT f01_201304280003.DAT f02_201304280000.dat f02_201304280002.dat... (2 Replies)
Discussion started by: arm
2 Replies

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

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

8. Shell Programming and Scripting

Perl : print the sequence number without missing number

Dear Perl users, I need your help to solve my problem below. I want to print the sequence number without missing number within the range. E.g. my sequence number : 1 2 3 4 5 6 7 8 11 12 13 14 my desired output: 1 -8 , 11-14 my code below but still problem with the result: 1 - 14 1 -... (2 Replies)
Discussion started by: mandai
2 Replies

9. Shell Programming and Scripting

print out missing files in a sequence

Hello all, I have several directories with a sequence of files like this IM-0001-0001.dcm IM-0001-0002.dcm IM-0001-0003.dcm IM-0001-0004.dcm IM-0001-0005.dcm I would like to print out the name of the file that is missing. I currently have the following ineffecient way to do this... (4 Replies)
Discussion started by: avatar_007
4 Replies

10. Programming

find the missing sequence in hash perl

Dear Perl's Users, Could anyone help me how to solve my problem. I have data with details below. TTY NAME SEQUENCES U-0 UNIX 0 U-1 UNIX 1 U-2 UNIX 2 <-- From 2 jump to 5 U-5 UNIX 5 U-6 UNIX 6 <-- From 6 jump to 20 U-20 ... (2 Replies)
Discussion started by: askari
2 Replies
Login or Register to Ask a Question