文章归档

最短shell代码实现乘法表

the first version:

[shell]
for i in {1..5}; do for j in {1..5}; do let k=$i*$j; echo $i*$j=$k; done; done;
[/shell]

then, i research for a while, and write the 2rd

[shell]
seq 5 | awk '{for(i=1;i<=$1;i++){printf($1 "*"i"="i*$1" ")};print""}'
[/shell]

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>