bash入门

输入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:                    [email protected]
#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

[root@Zabbix-M bash]# sh demo02HelloWorld.sh 
Hello World
Hello World
Hello World
Hello World
Hello World
Hello World

 

你可能感兴趣的:(bash编程入门到精通,bash,开发语言)