Reputation: 198
I'm trying to create a file with all the numbers up 75 million on every line.
I'm typing in my terminal using Bash:
seq 1 75000000 > myfile.csv
But anything above 1 million gets turned into scientific notation and I'd want everything as integer (i.e. 7.31896e+07)
Do you have any idea how to achieve this?
Upvotes: 4
Views: 3075
Reputation: 125928
seq
can take a printf-style format string to control its output. f
format with a "precision" of 0 (i.e. nothing after the decimal point, which leaves off the decimal point itself) should do what you want:
$ seq 74999998 75000000
7.5e+07
7.5e+07
7.5e+07
$ seq -f %1.0f 74999998 75000000
74999998
74999999
75000000
Upvotes: 10
Reputation: 113924
Observe that this produces integers:
$ seq 74999998 75000000
74999998
74999999
75000000
While this produces floating point numbers:
$ seq -f '%.5g' 74999998 75000000
7.5e+07
7.5e+07
7.5e+07
The output format of seq
is controlled by the -f
options.
How is the -f
option being applied in your case? One possibility is that your shell has an alias defined for seq
that applies this option. For example:
$ alias seq="seq -f '%.5g'"
$ seq 74999998 75000000
7.5e+07
7.5e+07
7.5e+07
You can determine if this is the case by running bash's builtin type
command:
$ type seq
seq is aliased to `seq -f '%.5g''
From man seq
:
-f, --format=FORMAT use printf style floating-point FORMAT
Upvotes: 1