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

bash – “echo”命令有什么替代方法吗?

发布时间:2020-12-15 22:09:21 所属栏目:安全 来源:网络整理
导读:在bash中有没有“echo”以外的命令可用于向终端显示文本? 优选地,可以输出到终端中的任何点. 解决方法 也许tput是你正在寻找的.例如,你可以像这样创建一个小菜单: #!/bin/bash# clear the screentput clear# Move cursor to screen location X,Y (top left
在bash中有没有“echo”以外的命令可用于向终端显示文本?

优选地,可以输出到终端中的任何点.

解决方法

也许tput是你正在寻找的.例如,你可以像这样创建一个小菜单:

#!/bin/bash

# clear the screen
tput clear

# Move cursor to screen location X,Y (top left is 0,0)
tput cup 3 15

# Set a foreground colour using ANSI escape. Not sure this works on OSX
tput setaf 3

# Set reverse video mode
tput rev
echo "S U S H I  M E N U  I T E M S"
tput sgr0

tput cup 5 17
echo "Please select an option"
tput sgr0

tput cup 7 15
echo "1. Sushi Sashimi Combo"

tput cup 8 15
echo "2. Omakase"

tput cup 9 15
echo "3. Chirashi"

tput cup 10 15
echo "4. Eel and Avacado Roll"


# Set bold mode 
tput bold
tput cup 12 15
read -p "Enter your choice [1-4] " choice

tput clear
tput sgr0
tput rc

echo "You chose $choice"

(编辑:李大同)

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

    推荐文章
      热点阅读