Check missing sequence

Do you know anyway (script) to check the missing sequence in the unix files or from database side?

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Lets assume that you have a

Lets assume that you have a file of files number sequences. That file named (list.txt) contain only numbers.

$ more list.txt
1
2
3
4
5
8
10
11
12
13
14

Here the sequence 6, 7 and 9 is missed. How to find the missing sequence? I have tried this script and it works fine:

> complete.txt
sort -nu list.txt > sorted.txt
s=`head -1 sorted.txt`
e=`tail -1 sorted.txt`
while [ $s -le $e ]
do
echo $s >> complete.txt
((s = $s + 1 ))
done
echo "Sequence missed:"
diff sorted.txt complete.txt | grep '^>'

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <ins> <del> <blockquote> <span> <center>
  • Lines and paragraphs break automatically.
  • Textual smileys will be replaced with graphical ones.
  • You may write mixed Arabic and English freely, line direction will be computed automaticaly

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Copy the characters (respecting upper/lower case) from the image.
Syndicate content