Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
up vote 4 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
This happened in my case when I scped a file which had Windows (dos) line endings. Running dos2unix (and this post) restored the sanity. Thanks! – Kedar Mhaswade Apr 21 at 16:53

Your Answer


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.