I'm using bash (CentOS 5) and looking to generate this output (Iassume I could use seq or echo together maybe?):1|1,2|2,3|3,....31|31,32|32,33|33,I googled seq examples for over two hours and the closest I can come up with is:echo {1..31}..{1..31} | tr ' ' '\n'which almost gives me what I want (but messes up when I change the .. to | or even |);A second number generation I need is formatted the same way but fordescending years, i.e.:2015|2015,2014|2014,...1938|1938,1937|1937,1936|1936,I've already manually typed out these two lists, but I would love anyinput on how I could have done this from the command line for futureneeds and to learn (seq or echo, i'm assuming).
Generate two sequences of numbers separated by |
shell;command line;text processing;seq
The following should do it:seq 0 31 | awk '{ print $1|$1,  }'in the descending case:seq 31 -1 0 | awk '{ print $1|$1,  }'These use awk to duplicate the number on each line, separated by apipe character.Or using pure bash (as suggested by DopeGhoti in a comment):for n in {0..31}; do printf %d|%d,\n $n $n; donefor n in {31..0}; do printf %d|%d,\n $n $n; done