输入helloworld并打印出颜色
黄色
[root@Zabbix-M bash]# cat demo01HelloWorld.sh
#!/bin/bash
#
#********************************************************************
#Author: jinwaner
#QQ: 3128743705
#Date: 2024-01-11
#FileName: demo01HelloWorld.sh
#URL: https://xxx.blog
#Description: For personal learning Bash
#Copyright (C): 2024 All rights reserved
#********************************************************************
varDemoHello1='Hello World'
echo ${varDemoHello1}
tput setaf 3
echo ${varDemoHello1}
echo ${varDemoHello1}
echo ${varDemoHello1}
printf "Hello World\n"
printf "Hello World\n"
printf "Hello World\n"
tput sgr0
执行脚本
[root@Zabbix-M bash]# bash demo01HelloWorld.sh
Hello World
Hello World
Hello World
Hello World
Hello World
Hello World
Hello World
绿色
[root@Zabbix-M bash]# cat demo02HelloWorld.sh
#!/bin/bash
#
#********************************************************************
#Author: jinwaner
#QQ: 18696607397@163.com
#Date: 2024-01-11 14:00:13
#FileName: demo02HelloWorld.sh
#URL: https://xxx.blog
#Description: For personal learning Bash
#Copyright (C): 2024 All rights reserved
#********************************************************************
hello="Hello World"
echo ${hello}
echo "Hello World"
tput setaf 2
printf "Hello World\n"
echo ${hello}
printf "Hello World\n"
printf "Hello World\n"
tput sgr0文章来源:https://www.toymoban.com/news/detail-809746.html
[root@Zabbix-M bash]# sh demo02HelloWorld.sh
Hello World
Hello World
Hello World
Hello World
Hello World
Hello World
文章来源地址https://www.toymoban.com/news/detail-809746.html
到了这里,关于bash入门的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!