bash – 一行上的Unix打印循环输出
发布时间:2020-12-15 21:04:19 所属栏目:安全 来源:网络整理
导读:我创建了这个脚本,我想在一行打印输出,我该怎么做? 这是我的剧本 #!/bin/bashecho "enter start and stop numbers"read start stopwhile [ $start -lt $stop ]doecho $startstart=`expr $start + 1`done 解决方法 使用printf或echo -n.另外,尝试使用start =
我创建了这个脚本,我想在一行打印输出,我该怎么做?
这是我的剧本 #!/bin/bash echo "enter start and stop numbers" read start stop while [ $start -lt $stop ] do echo $start start=`expr $start + 1` done 解决方法
使用printf或echo -n.另外,尝试使用start = $(($start 1))或start = $[$start 1]而不是返回tick来增加变量.
#!/bin/bash echo "enter start and stop numbers" read start stop while [ $start -lt $stop ] do printf "%d " $start start=$(($start + 1)) done #!/bin/bash echo "enter start and stop numbers" read start stop while [ $start -lt $stop ] do echo -n "$start " # Space will ensure output has one space between them start=$[$start + 1] done (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |