`seq': Print numeric sequences ============================== `seq' prints a sequence of numbers to standard output. Synopses: seq [OPTION]... [FIRST [INCREMENT]] LAST... `seq' prints the numbers from FIRST to LAST by INCREMENT. By default, FIRST and INCREMENT are both 1, and each number is printed on its own line. All numbers can be reals, not just integers. The program accepts the following options. Also see Note: Common options. `-f FORMAT' `--format=FORMAT' Print all numbers using FORMAT; default `%g'. FORMAT must contain exactly one of the floating point output formats `%e', `%f', or `%g'. `-s STRING' `--separator=STRING' Separate numbers with STRING; default is a newline. The output always terminates with a newline. `-w' `--equal-width' Print all numbers with the same width, by padding with leading zeroes. (To have other kinds of padding, use `--format'). If you want to use `seq' to print sequences of large integer values, don't use the default `%g' format since it can result in loss of precision: $ seq 1000000 1000001 1e+06 1e+06 Instead, you can use the format, `%1.f', to print large decimal numbers with no exponent and no decimal point. $ seq --format=%1.f 1000000 1000001 1000000 1000001 If you want hexadecimal output, you can use `printf' to perform the conversion: $ printf %x'\n' `seq -f %1.f 1048575 1024 1050623` fffff 1003ff 1007ff For very long lists of numbers, use xargs to avoid system limitations on the length of an argument list: $ seq -f %1.f 1000000 | xargs printf %x'\n' |tail -3 f423e f423f f4240 To generate octal output, use the printf `%o' format instead of `%x'. Note however that using printf works only for numbers smaller than `2^32': $ printf "%x\n" `seq -f %1.f 4294967295 4294967296` ffffffff bash: printf: 4294967296: Numerical result out of range On most systems, seq can produce whole-number output for values up to `2^53', so here's a more general approach to base conversion that also happens to be more robust for such large numbers. It works by using `bc' and setting its output radix variable, OBASE, to `16' in this case to produce hexadecimal output. $ (echo obase=16; seq -f %1.f 4294967295 4294967296)|bc FFFFFFFF 100000000 Be careful when using `seq' with a fractional INCREMENT, otherwise you may see surprising results. Most people would expect to see `0.3' printed as the last number in this example: $ seq -s' ' 0 .1 .3 0 0.1 0.2 But doesn't happen on most systems because `seq' is implemented using binary floating point arithmetic (via the C `double' type) - which means some decimal numbers like `.1' cannot be represented exactly. That in turn means some nonintuitive conditions like `.1 * 3 > .3' will end up being true. To work around that in the above example, use a slightly larger number as the LAST value: $ seq -s' ' 0 .1 .31 0 0.1 0.2 0.3 In general, when using an INCREMENT with a fractional part, where (LAST - FIRST) / INCREMENT is (mathematically) a whole number, specify a slightly larger (or smaller, if INCREMENT is negative) value for LAST to ensure that LAST is the final value printed by seq.
automatically generated by info2www version 18.104.22.168