Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sequence control

Status
Not open for further replies.

malpa

Technical User
Feb 8, 2004
122
CO

Hi

I want to make a program to control the absence of archives, with base in the generation sequence.

filename_xxxx_DDMMYY.pyy

filename_9999_150808.p00
filename_9999_150808.p01
filename_9999_150808.p02
filename_0001_160808.p00
filename_0002_170808.p00
filename_0002_170808.p01
filename_0002_170808.p03
filename_0004_180808.p00

xxxx-> 0000 - 9999
yy-> 00-FF


Every day several archives are generated. What requires is to validate that it does not lack some file.

in this case not is the file filename_0002_170808.p02 and
filename_0003_??????.???


Thanks malpa

 
What have you tried so far and where in your code are you stuck ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Hi PVH

This is my initial programm. The structure of the filenames will change to:

filename_xxxx_DDMMYY.pyy


#!/usr/bin/bash
ls cl20* > cl20.txt
awk -v c=${i} -F"." ' BEGIN{l=1}{if (NR==1) { major = substr($1,5,4)+0; minor = substr($1,5,4)+0 }
if ( substr($1,5,4)+0 > major ) major = substr($1,5,4)+0
if ( substr($1,5,4)+0 < minor ) minor = substr($1,5,4)+0
f=substr($1,5,4)+0
file[f]=1
}
END {
print FILENAME
print minor "," major > "f.txt"

#through 0000

if ( (major+1)==10000 ) {
#print "yes"
for ( l=major;l>=1;l-- )
{
#if ( l in file ) {print l > c"_list.txt";limit=l}
if ( l in file ) {limit=l}
}
for ( t=limit;t<=major;t++) { if ( t in file ) print t > c"_list.txt" }
for (j=1;j<=(limit-1);j++)
{
j=sprintf("%0+4s",j)
if (j in file ) {print j >> c"_list.txt" }
}
#for ( t=limit;t<=major;t++) { if ( t in file ) print t }


}
else {
for ( k = minor; k <= major; k++ ){
if ( k in file ) delete file[k]
else {
printf"%0+4s\n", k >> "f.txt"
}
}
}
} ' cl20.txt

cl20.txt
--------
cl203897.p00
cl203898.p00.Z
cl203898.p01.Z
cl203898.p02.Z
cl203898.p03.Z
cl203898.p04.Z
cl203898.p05.Z
cl203898.p06.Z
cl203898.p07.Z
cl203898.p08.Z
cl203898.p09.Z
cl203898.p0a.Z
cl203898.p0b.Z
cl203898.p0c.Z
cl203898.p0d.Z
cl203898.p0e.Z
cl203898.p0f.Z
cl203898.p10.Z
cl203898.p11.Z
cl203898.p12.Z
cl203898.p13.Z
cl203898.p14.Z
cl203898.p15.Z
cl203898.p16.Z
cl203898.p17.Z
cl203898.p18.Z
cl203898.p19.Z
cl203898.p1a.Z
cl203898.p1b.Z
cl203900.p00
cl203900.p01
cl203900.p02
cl203900.p03
cl203900.p04
cl203900.p05
cl203900.p06
cl203900.p07
cl203900.p08
cl203900.p09
cl203900.p0a
cl203900.p0b
cl203900.p0c
cl203900.p0d
cl203900.p0e
cl203900.p0f
cl203900.p10
cl203900.p11
cl203900.p12
cl203900.p13
cl203900.p14
cl203900.p15
cl203900.p16
cl203900.p17
cl203900.p18
cl203900.p19
cl203900.p1a
cl203900.p1b
cl203901.p00

Initial output
faltan.txt
----------
3897,3901
3899

But what happend if the file cl203900.p1a doesn´t appear ?

and if the sequence depends on the date??


Thanks malpa.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top