Find the missing sequence


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Find the missing sequence
# 1  
Old 07-31-2014
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
Code:
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 file seq 02 and 04 is missing

so the output shoould be like this
Code:
02231587
04231587

is missing and leading zero is important.

thanks in advance
Moderator's Comments:
Mod Comment Please use CODE tags (not QUOTE tags) when displaying sample input, output, and code segments.

Last edited by Don Cragun; 08-02-2014 at 05:02 PM.. Reason: Change QUOTE tags to CODE tags.
# 2  
Old 07-31-2014
Hello sagar_1986,
I have a few to questions pose in response first:-
  • What have you tried so far?
  • What output/errors do you get?
  • What OS and version are you using?
  • What are your preferred tools? (C, shell, perl, awk, etc.)
  • What logical process have you considered? (to help steer us to follow what you are trying to achieve)
Most importantly, What have you tried so far?

There are probably many ways to achieve most tasks, especially if there are only a few lines (and therefore IO is not so much of a worry) Giving us an idea of your style and thoughts will help us guide you to an answer most suitable to you so you can adjust it to suit your needs in future.


We're all here to learn and getting the relevant information will help us all.



Regards,
Robin
# 3  
Old 07-31-2014
Hello rbatte1,

its a shell script,actually i am giving missing file status for approx 350 types.
But till now i was giving just count and missing count for month,but now i want to give exact sequence for missing files.
Now i have tried to put all sequence in one file and comparing them output is driven but my requirement is without comparing (i.e. not in file) can we do it ??
i can get sequence i.e. 00-23 using cut command but my exact problem is how to get missing sequence and put them into desired format as stated above

Also there is one more problem i would like to discuss that,i am learning Unix and till date my biggest problem is transposing rows into column,i have already posted that thread but till i didn't understand how to figure it out.

My output is like this

Quote:
folder1,24,24,24,24,24,24,total_available,total_expected,total missing,missing seq
folder2,24,24,24,24,24,24,total_available,total_expected,total missing,missing seq
and so on.
i want to transpose rows into column.Plz explain me how to figure it out.
Note :number of rows may vary Hence the transpose script first read how many rows and then convert it into columns

Thanks in advance
# 4  
Old 08-01-2014
Code:
awk -F '.' 'NR == 1{t=substr($1,5); a=00}
  {b=substr($1, 3, 2); for(i=a+1; i<b+0; i++)
    printf "%02d%d\n", i, t; a=b}
  END {for(i=a+1; i<=23; i++) printf "%02d%d\n", i, t}' file

# 5  
Old 08-01-2014
Dear SriniShoo,

Thanks for the reply,it works fine for me,but will u plz elaborate the step by step functionality of code so that i can rewrite the code again as per my requirement
# 6  
Old 08-01-2014
In the code
1. I am extracting the 3rd and 4th character
2. Since the list is incremental, I am checking current number is +1 of the previous number
3. If not, I am printing all the numbers between previous and current number
# 7  
Old 08-02-2014
Other way to accomplish the task...

Input file:

Code:
cat list.txt
df00231587.dat
df01231587.dat
df03231587.dat
df05231587.dat
df0631587.dat 
df0731587.dat 
df08231587.dat 
df09231587.dat 
df11231587.dat 
df10231587.dat 
df19231587.dat 
df18231587.dat 
df17231587.dat 
df16231587.dat

if u run the below script..

Code:
awk -F"." '{
b=substr($1,5);
a[NR]=substr($1,3,2);
n=NR;
}
END {
for(l=0;l<=23;l++)
{
s=sprintf("%02d",l);
for(i=1;i<=n;i++)
{
if(s != a[i])
{
c=c+1;
}
}
if(c==n)
{
print s b;
}
c=0;
}
}' list.txt

the output is..

Code:
02231587
04231587
12231587
13231587
14231587
15231587
20231587
21231587
22231587
23231587

---------- Post updated at 12:26 PM ---------- Previous update was at 12:25 PM ----------

the above are missing files from list.txt
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

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

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

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

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