Generate two sequences of numbers separated by "|"

My twists:

  • pure awk

    awk 'BEGIN{for(;n<31;)print ++n"|"n","}'
    
  • printf + xargs

    printf '%s\n' {0..31} | xargs -I {} echo "{}|{},"
    
  • repeat loop in zsh

    n=0; repeat 32 echo "$n|$((n++)),"
    

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 a pipe character.

Or using pure bash (as suggested by DopeGhoti in a comment):

for n in {0..31}; do printf "%d|%d,\n" $n $n; done
for n in {31..0}; do printf "%d|%d,\n" $n $n; done

seq 100|sed 's/.*/&|&,/'

...should do it fine...

With just a shell:

i=-1 x=31
while [ "$i" -lt "$x" ]
do    echo "$((i+=1))|$i,"
done