To find missing numbers from a number series


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers To find missing numbers from a number series
# 1  
Old 05-23-2010
To find missing numbers from a number series

Hi,

My requirement is I have an input file with a continuous series from 10000 to 99999. I have some numbers missing from those series. I want a output file which produces those missing numbers.

Eg: 10002, 99999 are missing from the series then the output file should contain those two numbers.

If possible please let me know if it can be done using one single command.
# 2  
Old 05-23-2010
you can try with ..
seq and diff command.
Code:
$seq 10000 99999 > temp_file
$diff temp_file your_file

it may be help full.
# 3  
Old 05-23-2010
Ok, I should have pasted it here.

>>>

Please read the rules of the forum. You should not duplicate the posts and that too you have tri-plicated it

Now to the question,

Is it a running series in sequence, then iterate through the file and report the missing number.
If its out of sequence, sort it and do the above.
# 4  
Old 05-23-2010
Quote:
Originally Posted by posix
you can try with ..
seq and diff command.
Code:
$seq 10000 99999 > temp_file
$diff temp_file your_file

it may be help full.


seq is not working, it is showing as command not found. Please provide some other alternative.
# 5  
Old 05-23-2010
Do not post classroom or homework problems in the main forums. Homework and coursework questions can only be posted in this forum under special homework rules.

Please review the rules, which you agreed to when you registered, if you have not already done so.

More-than-likely, posting homework in the main forums has resulting in a forum infraction. If you did not post homework, please explain the company you work for and the nature of the problem you are working on.

If you did post homework in the main forums, please review the guidelines for posting homework and repost.

Thank You.

The UNIX and Linux Forums.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Check/print missing number in a consecutive range and remove duplicate numbers

Hi, In an ideal scenario, I will have a listing of db transaction log that gets copied to a DR site and if I have them all, they will be numbered consecutively like below. 1_79811_01234567.arc 1_79812_01234567.arc 1_79813_01234567.arc 1_79814_01234567.arc 1_79815_01234567.arc... (3 Replies)
Discussion started by: newbie_01
3 Replies

2. Shell Programming and Scripting

Moving decimal point in a series of numbers

Hi, i need to move the decimal point from a file listing some numbers like this : 49899.50 49914.55 49894.48 49939.65 49879.44 49919.57 49934.62 49944.67 49954.72 (1 Reply)
Discussion started by: Board27
1 Replies

3. Shell Programming and Scripting

AWK series of numbers

Hi, I have a dataset say 1 2 3 4 5 5 6 7 6 7 8 9 I was wondering if there is a way to add another column with the following style... 1 2 3 4 xyz_1 5 5 6 7 xyz_2 6 7 8 9 xyz_3 It would be greatly appreciated if I can have an option of specifying what to write instead of xyz,... (8 Replies)
Discussion started by: jacobs.smith
8 Replies

4. Shell Programming and Scripting

How do i find the first number in each line and insert dummy string into the missing columns?

Hi, I have one input file with the following content: MY_inpfile.txt Aname1 Cname1 Cname2 1808 5 Aname2 Cname1 1802 47 Bname1 ? 1819 22 Bname2 Cname1 1784 11 Bname3 1817 9 Zname1 Cname1 1805 59 Zname2 Cname1 Cname2 Cname3 1797 27 Every line in my input file have a 4 digit... (5 Replies)
Discussion started by: Szaffy
5 Replies

5. Shell Programming and Scripting

How to get the number series in between?

Hi Guys, Can someone give me a simple script that can extract the numbers in between numbers from start to end. As shown below, it start from 100 to 110 and revealed the numbers in between. INPUT: 100 - 110 DESIRED OUTPUT: 100 101 102 103 104 105 106 107 (6 Replies)
Discussion started by: pinpe
6 Replies

6. Homework & Coursework Questions

Help with shell script to find sum of first n numbers of Fibonacci series

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Shell script to find sum of first n numbers of Fibonacci series 2. Relevant commands, code, scripts,... (0 Replies)
Discussion started by: Kshitija
0 Replies

7. Shell Programming and Scripting

How to code a series of numbers in SH

Hi. How can I write this in a shorter way? for NUMs in 1 2 3 4 5 6 I looked at the"seq" command, but I do not think that is what I want. Can I code for NUMs (1..7) Hey!! Is that it? (8 Replies)
Discussion started by: Ccccc
8 Replies

8. Shell Programming and Scripting

How to sort out the latest one from a series of numbers?

Hi, I have a directory which contains a number of sub directories. They are named as 1.0.0, 1.0.1, 1.0.2...1.1.0..1.1.1...1.2.0..and so on.. Basically these are the tags created at the time of release. Tags are named as major.minor.buildnumber format for modules. Now I have to search the... (2 Replies)
Discussion started by: bhaskar_m
2 Replies

9. Shell Programming and Scripting

How to generate a series of numbers

Hi All, I have a requirement where in I have an input as follows:- input=1-4,6,8-10,12-15 I need to explode this range into an output file as follows:- 1 2 3 4 6 8 9 10 12 13 14 15 My input may vary like 1,5-9,11-13,15-17....... (3 Replies)
Discussion started by: rony_daniel
3 Replies
Login or Register to Ask a Question