加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

如何在bash中显示和刷新多行

发布时间:2020-12-15 18:59:05 所属栏目:安全 来源:网络整理
导读:我正在编写安装脚本,并希望在脚本进行过程中显示脚本的状态. 例: var1="pending"var2="pending"var3="pending"print_status () {echo "Status of Item 1 is: "$var1""echo "Status of Item 2 is: "$var2""echo "Status of Item 3 is: "$var3""}code that do
我正在编写安装脚本,并希望在脚本进行过程中显示脚本的状态.

例:

var1="pending"
var2="pending"
var3="pending"

print_status () {
echo "Status of Item 1 is: "$var1""
echo "Status of Item 2 is: "$var2""
echo "Status of Item 3 is: "$var3""
}

code that does something and then refreshes the
output above as the status of each variable changes.
这段代码应该给你一个想法:
while :; do
    echo "$RANDOM"
    echo "$RANDOM"
    echo "$RANDOM"
    sleep 0.2
    tput cuu1 # move cursor up by one line
    tput el # clear the line
    tput cuu1
    tput el
    tput cuu1
    tput el
done

使用man tput获取更多信息.要查看功能列表,请使用man terminfo

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读