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 Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sequence files

Status
Not open for further replies.

oznasuer

Technical User
Joined
Jan 28, 2003
Messages
2
Location
TR
How can I find the missing sequence in a file list with a "for" or a "while" command?
For example:
5995
5996
5997
5998
5999
6001
6002

I want to find the missing sequence at this list using "for" or "while".
Thanks for your helps.
 
Hello oznasuer,

ox=0
while read xx
do
nx=`expr $ox + 1`
if [ $xx -ne $nx ] ;then
echo $xx $ox
fi
ox=$xx
done < seqfile

regards Gregor.

Gregor.Weertman@mailcity.com
 

Hello oznasuer,
seqfile contains
5995
5996
5997
5998
5999
6001
6002

#!/bin/ksh
#Script to find the missing sequence in file of numerals

tmpfile=`cat seqfile`
tmpfile2=`cat seqfile`
flag=0

echo the missing sequence is

for num in $tmpfile
do

tmpnum=$num
tmpnum=`expr $tmpnum + 1 `


for num2 in $tmpfile2
do

if [ $num2 -eq $tmpnum ]
then
flag=1
break
else
flag=0
continue
fi


done

if [ $flag -ne 1 ]
then
tt=`expr $tmpnum + 1 `
echo $tmpnum
else
continue
fi

done

#end of the script



the output is like this:
the missing sequence
6000
6003

cheers,
Santosh.K.B

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top