Difference between revisions of "Seq"
From Linuxintro
imported>ThorstenStaerk |
imported>ThorstenStaerk |
||
Line 18: | Line 18: | ||
the square of 7 is 49 | the square of 7 is 49 | ||
the square of 8 is 64 | the square of 8 is 64 | ||
+ | |||
+ | To show all ascii characters you can use the following [[command]]: | ||
+ | for l in $(seq 0 1 7); do for i in $(seq 0 1 7); do for n in $(seq 0 1 7); do \ | ||
+ | echo -en "\0${l}${i}${n} "; done; done; done | ||
= See also = | = See also = | ||
* [[bAsh scripting tutorial]] | * [[bAsh scripting tutorial]] |
Revision as of 11:47, 20 February 2012
seq is a command to show a sequence of numbers. For example the sequence from 1 to 5 can be shown like this:
# seq 1 5 1 2 3 4 5
seq is great to be used in for loops like this:
# for i in $(seq 1 8); do echo "the square of $i is $(($i*$i))"; done the square of 1 is 1 the square of 2 is 4 the square of 3 is 9 the square of 4 is 16 the square of 5 is 25 the square of 6 is 36 the square of 7 is 49 the square of 8 is 64
To show all ascii characters you can use the following command:
for l in $(seq 0 1 7); do for i in $(seq 0 1 7); do for n in $(seq 0 1 7); do \ echo -en "\0${l}${i}${n} "; done; done; done