creating a sequence of numbers, one per line in a file

There is already a command for this:

seq 100 104

will print these numbers on separate lines:

100
101
102
103
104

So just direct this output into a file:

seq 100 104 > my_file.txt

and seq 100 2 104 will print in increments of two, namely: 100, 102, 104


Linux ships with the seq command which does exactly that. If you don't have the seq command, it's an easy one-liner:

i=100; while [ $i -le 104 ]; do echo $i; i=$((i+1)); done >b.txt

or in ksh/bash/zsh

for ((i=100; i<=104; i++)); do echo $i; done >b.txt

or in zsh

print -l {100..104} >b.txt

bash:

printf '%s\n' {100..105}

perl:

perl -le 'print for 100..104'

bc:

echo 'for (i = 100 ; i <= 104 ; ++i) i' | bc

dc:

echo '100 104 sb [p 1 + d lb !<m] sm lm x' | dc