程序:
#!/bin/bash function showAlertMsg(){ echo -e "\e[1;31m"$1"\e[0m" } function showHighlightMsg(){ echo -e "\e[1;32m"$1"\e[0m" } echo "Hello,world" echo hello,world echo 'hello,world' printf "Hello,world\n" printf "%-10s%-10s%-10s\n" 'Andy' 'Bill' 'Cindy' echo -e "\e[1;31m This is red text \e[0m" showAlertMsg "System Exception" showHighlightMsg "Attention" echo -e "\e[1;44m"Hollo world"\e[0m"
执行结果:
[root@localhost bashs]# sh print.sh Hello,world hello,world hello,world Hello,world Andy Bill Cindy This is red text System Exception Attention Hollo world
执行效果: