Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have a file with many numbers, with each number on one line. My goal is to find the numbers that are missing. I'm trying to generate the sequence of all the numbers with seq

start=$(head -1 numbers.txt)
finish=$(tail -1 numbers.txt)
seq $start $finish > all_numbers.txt

I get the following error message

seq: invalid floating point argument: 4106
Try 'seq --help' for more information.

I'm baffled as 4106 is clearly not a floating point number.

After this I plan to use diff to find the missing numbers. Can someone tell me why seq is behaving this way?

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

Probably there's a hidden character after 4106, most probably a carriage return if the file comes from the Microsoft world which you'd need to strip first (or do the whole thing with awk).

$ seq 1 $'2\r'
seq: invalid floating point argument: 2
Try `seq --help' for more information.
$ echo seq 1 $'2\r'
seq 1 2

It's there, but you can't see it. When output to a terminal, it (usually) only moves the cursor to the beginning of the line.

With ksh93, zsh or bash, try:

printf '<%q>\n' "$start"

to see what it contains.

share|improve this answer
    
Yep that was the issue. –  nikhil Oct 4 '12 at 17:37
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.