command-line – How to Display Numbers in Reverse Order Using seq(1)

.seqcommand line

I have iterate over numbers in various order. I am able to display them in increasing order, even with steps like:

$ seq --separator="," 1 10
1,2,3,4,5,6,7,8,9,10
$ seq --separator="," 1 2 10
1,3,5,7,9

I am also able to display them in reverse order, neither continuous nor step wise.

$ seq --separator="," 10 1   
$ seq --separator="," 10 2 1

No output for above commands.

My shell details:

$ bash --version
GNU bash, version 3.2.25(1)-release (x86_64-redhat-linux-gnu)
Copyright (C) 2005 Free Software Foundation, Inc.

Let me know how I would be able to display the numbers in descending order?

Best Answer

use negative increment

seq -s, 10 -2 1
10,8,6,4,2
Related Question