Output in Linux Console

1. echo

i=3;
j=5;
let sum=i+j;
echo "sum = $sum";

echo can set the text attributes and color:

echo -e "\e[1;31m This is the red text \e[0m;

 

usage: 

echo -e "\e[attribute_code;text_color_code;background_color_codem text_content \e[0m"

 

attribute_code: 00-none 01-bold 04-underscore 05-blink 07-reverse 08-concealed
text_color_code: 30-black 31-red 32-green 33-yellow 34-blue 35-magenta 36-cyan 37-white
background_color_code: 40-black 41-red 42-green 43-yellow 44-blue 45-magenta 46-cyan 47-white

2. printf
It uses the same parameter format with the printf function in language C. Using space as the parameter separater.

printf "%-5s %-10s %-4s" No Name Core
printf "%-5d %-10s %-4.2f" 1 Tom 70.231

 

 

posted on 2013-02-17 13:34  name2579  阅读(347)  评论(0编辑  收藏  举报

导航