Shell Practice Applet Exercise--99 multiplication table

Source: Internet
Author: User

Recently, I was going to review the shell, just to see the shell operation, and to write a simple 99 multiplication table like a beginner. It is suggested that you can run shell scripts directly in Http://www.runoob.com/try/runcode.php?filename=helloworld&type=bash if you do not want to install Linux environments.

First, the previous code

#!/bin/bash

#使用while循环
I=1;
While [$i-le 9];d o #-le means less than or equal to
J=1;
While [$j-le $i];d o
Echo-n ${j} "x" $[i] "=" ' Expr $i \* $j ' ""; #echo-n means that the output does not wrap, string stitching
j= ' expr $j + 1 '; #下标加1, you can also use the Let J + +
Done
echo ""; #换行
i= ' expr $i + 1 ';
Done

#使用for循环

echo "For loop implementation"
For k in ' SEQ 1 9 ';d o #使用seq increment sequence
for (m=1; $m <= $k; m++);d o
Echo-n ${m} "x" ${k} "=" ' Expr $m \* $k ' "";
Done
echo "";
Done

Operation Result:

Shell Practice Applet Exercise--99 multiplication table

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.