How to take the missing sequence Number?

Am using unix aix KSH...
I have the files called

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 :

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

I'm really not certain if this is what you're looking for, if it's not please provide a little more info:

#!/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
1 Like

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

A solution with awk:

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

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

May be you have to extract the number from the first line :slight_smile:

1 Like

can u tell me how to extract the first line ...

I'm a bit confused about what you mean. Are there blank lines before the first line with the number, and that what needs to be skipped?

This will skip blank lines:

awk 'NF < 1 {next;} p && p != $1 { for( i = p; i < $1; i++ ) print i; } {p = $1 + 1 }'