printf+awk完美结合

[root@keepalived_master scripts]# cat echo_color.sh

#!/bin/bashecho -e “\033[31mplease input one number: \033[0m” –>红色echo -e “\033[32mplease input one number: \033[0m”–>绿色echo -e “\033[33mplease input one number: \033[0m”–>黄色echo -e “\033[34mplease input one number: \033[0m”–>蓝色echo -e “\033[35mplease input one number: \033[0m”–>粉色echo -e “\033[36mplease input one number: \033[0m”–>青色echo -e “\033[37mplease input one number: \037[0m”–>白色

[root@keepalived_master scripts]# cat printf_color.sh

#!/bin/bashprintf “\033[31mplease input one number: \033[0m\n”printf “\033[32mplease input one number: \033[0m\n”printf “\033[33mplease input one number: \033[0m\n”printf “\033[34mplease input one number: \033[0m\n”printf “\033[35mplease input one number: \033[0m\n”printf “\033[36mplease input one number: \033[0m\n”printf “\033[37mplease input one number: \033[0m\n”

实例4:

[root@keepalived_master ~]# netstat -n | awk ‘/^tcp/{++S[$NF]}END{for(key in S) print key,”\t”,S[key]}’TIME_WAIT 243SYN_SENT 1ESTABLISHED 58

脚本1:

[root@keepalived_master ~]# cat analyze_web_log.sh

#!/bin/bash# create author of cfwl# create date of 2013-10-12# scripts function analyze web site access log# print web site log and sortcat /application/nginx-1.2.9/logs/access.log | awk ‘{print $1,$4,$9,$19,$22}’ |sort | uniq -c | sort -nr

脚本2:

[root@keepalived_master ~]# cat funtion_analyze_web_log.sh

#!/bin/bash# create author of cfwl# create date of 2013-10-12# scripts function analyze web site access logsh analyze_web_log.sh|awk ‘BEGIN{ print “—————————————————————————-“; print “| Total | Access_IP | Access_Date | State | Access_browser |”; print “—————————————————————————-“;}{ printf “| %-5s | %-14s | %-11s | %-5s | %-15s |\n”,$1,$2,$3,$4,$5,$6;}END{ print “—————————————————————————-“;}’

本文出自 “人生有梦而精彩” 博客,,请务必保留此出处

当你能飞的时候就不要放弃飞

printf+awk完美结合

相关文章:

你感兴趣的文章:

标签云: