[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
"
printf "%-10s%-10s%-10s
" '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

执行效果:

原文地址:https://www.cnblogs.com/heyang78/p/12540210.html