Checking missing data's sequence (shell script | UNIX command)


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Checking missing data's sequence (shell script | UNIX command)
# 1  
Old 11-15-2012
[Solved] Checking missing data's sequence (shell script | UNIX command)

Dear All members,

i have some trouble here, i want to ask your help. The case is:

I have some data, it's like:
-ABCD1234
-ABCD1235
-ABCD1237
-BCDE1111
-BCDE1112
-BCDE1114

there is some missing data's sequence (the format is: ABCD = name 1234 = sequence).

I want to print the missing sequence (ABCD1236 and BCDE1113) and direct into one file.
Ex:
~more missing-sequence.txt
ABCD1236
BCDE1113

the data above is missing in my directory. Can someone help me to give me an example of shell script to check the missing file?
# 2  
Old 11-16-2012
Code:
#!/bin/bash

find . -type f | sed 's/\.\///g' | sort > file_list.dat

awk ' { print substr($1,1,4) } ' file_list.dat | uniq | while read name
do
        str_seq=$( sort file_list.dat | grep $name | head -1 | cut -c 5-8 )
        end_seq=$( sort file_list.dat | grep $name | tail -1 | cut -c 5-8 )

        if echo $str_seq | egrep -q '^[0-9]'
        then
                for sq in $( seq $str_seq $end_seq )
                do
                        if [ ! -f "${name}${sq}" ]
                        then
                                echo "${name}${sq} missing."
                        fi
                done
        fi
done

This User Gave Thanks to Yoda For This Post:
# 3  
Old 11-16-2012
Code:
$ nawk 'NR==1{name=substr($0,1,4);seq=substr($0,5,4);next}{name1=substr($0,1,4);seq1=substr($0,5,4); if(name == name1){for(i=seq+1;i<seq1;i++){print name""i}}name=name1;seq=seq1;}' input.txt
ABCD1236
BCDE1113

This User Gave Thanks to itkamaraj For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Compilation error character is missing-UNIX shell script

Dear Friends, Regarding Compilation error character is missing-unix shell script I am new to unix shell script. My requirement is --I need to find out 3 files in my UBM unix directory,if any one(CMUSER) file is available means,then i need to exit from my unix script, Below is my unix... (2 Replies)
Discussion started by: Joseph2017
2 Replies

2. Shell Programming and Scripting

How to find a missing file sequence using shell scripting?

Hey guys, I want the below files to be processed with the help of BASH so that i will be able to find the missing file names : PP01674520141228X.gz PP01674620141228X.gz PP01674820141228X.gz PP01674920141228X.gz PP01675420141228X.gz PP01675520141228X.gz PP01676020141228X.gz . . . .... (4 Replies)
Discussion started by: TANUJ
4 Replies

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

4. Shell Programming and Scripting

How can i run sql queries from UNIX shell script and retrieve data into text docs of UNIX?

Please share the doc asap as very urgently required. (1 Reply)
Discussion started by: 24ajay
1 Replies

5. Shell Programming and Scripting

Data export UNIX shell script

Hi, I want to write a shell script which connect to my database with the following credentials : User name : user PWD : rap_user_1 Hostname : app.Unix.Gsm1900.Org Port : 7862 SID : PTNC1 Once connected to DB i want to fetch data with the help of a SQL statement and expoet... (4 Replies)
Discussion started by: neeraj617
4 Replies

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

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

8. Shell Programming and Scripting

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... (7 Replies)
Discussion started by: Venkatesh1
7 Replies

9. Shell Programming and Scripting

Unix script for Checking sequence

Hello, I need Unix script for Checking sequence and get output in a file for missing sequences information. We are moving archive log to a server for DR .if any files miss from sequence DR will fails. so we need script to monitor sequence of files which are FTP from the Production servers .... (2 Replies)
Discussion started by: Rata_raj
2 Replies

10. Shell Programming and Scripting

How to extract data using UNIX shell script?

Hello All, I am starting with UNIX. Any help is highly appreciated. How to extract data using UNIX shell script? And how do you export data using UNIX shell scripts into Microsoft Excel format? Thank you. (3 Replies)
Discussion started by: desiondarun
3 Replies
Login or Register to Ask a Question