[bash] 打印到屏幕相关语法

程序:

#!/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

执行效果:

posted @ 2020-03-21 17:06  逆火狂飙  阅读(254)  评论(0)    收藏  举报
生当作人杰 死亦为鬼雄 至今思项羽 不肯过江东