首页 新闻 搜索 专区 学院

shell脚本中echo ""的作用

0
悬赏园豆:5 [已解决问题] 解决于 2021-02-24 16:11

!/bin/bash

for a in seq 1 9
do
for b in seq 1 9
do
if [ $a -ge $b ];then
echo -en "$a x $b = $(expr $a * $b) "
fi
done
echo ""
##shell脚本中echo ""的作用
done

如上 脚本中:
echo ""

shell脚本中echo ""的作用

不加入echo ""输出结果是这样的:
[root@binary scriptshell]# bash for66.sh
1 x 1 = 1 2 x 1 = 2 2 x 2 = 4 3 x 1 = 3 3 x 2 = 6 3 x 3 = 9 4 x 1 = 4 4 x 2 = 8 4 x 3 = 12 4 x 4 = 16 5 x 1 = 5 5 x 2 = 10 5 x 3 = 15 5 x 4 = 20 5 x 5 = 25 6 x 1 = 6 6 x 2 = 12 6 x 3 = 18 6 x 4 = 24 6 x 5 = 30 6 x 6 = 36 7 x 1 = 7 7 x 2 = 14 7 x 3 = 21 7 x 4 = 28 7 x 5 = 35 7 x 6 = 42 7 x 7 = 49 8 x 1 = 8 8 x 2 = 16 8 x 3 = 24 8 x 4 = 32 8 x 5 = 40 8 x 6 = 48 8 x 7 = 56 8 x 8 = 64 9 x 1 = 9 9 x 2 = 18 9 x 3 = 27 9 x 4 = 36 9 x 5 = 45 9 x 6 = 54 9 x 7 = 63 9 x 8 = 72 9 x 9 = 81 [root@binary scriptshell]#
加入echo “”结果如下:
1 x 1 = 1
2 x 1 = 2 2 x 2 = 4
3 x 1 = 3 3 x 2 = 6 3 x 3 = 9
4 x 1 = 4 4 x 2 = 8 4 x 3 = 12 4 x 4 = 16
5 x 1 = 5 5 x 2 = 10 5 x 3 = 15 5 x 4 = 20 5 x 5 = 25
6 x 1 = 6 6 x 2 = 12 6 x 3 = 18 6 x 4 = 24 6 x 5 = 30 6 x 6 = 36
7 x 1 = 7 7 x 2 = 14 7 x 3 = 21 7 x 4 = 28 7 x 5 = 35 7 x 6 = 42 7 x 7 = 49
8 x 1 = 8 8 x 2 = 16 8 x 3 = 24 8 x 4 = 32 8 x 5 = 40 8 x 6 = 48 8 x 7 = 56 8 x 8 = 64
9 x 1 = 9 9 x 2 = 18 9 x 3 = 27 9 x 4 = 36 9 x 5 = 45 9 x 6 = 54 9 x 7 = 63 9 x 8 = 72 9 x 9 = 81

小苑儿~的主页 小苑儿~ | 初学一级 | 园豆:189
提问于:2021-02-24 10:31
< >
分享
最佳答案
0

echo的作用 输出字符串
格式 echo "字符串内容"

收获园豆:5
中控易动 | 小虾三级 |园豆:796 | 2021-02-24 13:30
其他回答(2)
0

将""""中的内容打印出来啊,但如果你在引号中加上了空格和#时,就不会有内容打印了

当你去掉引号中的空格或#时,都可以正常打印

何以清欢渡 | 园豆:6 (初学一级) | 2021-02-24 11:01
0

echo的作用的输出内容,
第一个for循环结束后,格式是第一种,在echo输出后会按着第二种格式输出,一行一行输出。

小苑儿~ | 园豆:189 (初学一级) | 2021-02-24 16:11
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册