码迷,mamicode.com
首页 > 系统相关 > 详细

一个shell脚本,让你的linux命令行酷炫起来

时间:2017-06-19 17:45:21      阅读:335      评论:0      收藏:0      [点我收藏+]

标签:==   $0   linux命令   命令   comm   grep   current   ifconf   roo   

#!/bin/bash

# This program is to modify showed marked
#
# biaoshi.sh 207
# by wangxianzheng 2011/12/20

PATH=/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin
echo "########execute $0 begin...##############"

SYSVER=$(head -n 1 /etc/issue |awk ‘{print $3}‘)

function modify_bashrc(){
echo "DST=$(NETCARD=$( ifconfig |grep -B1 192.168 |awk ‘/eth/ {if ($1=="eth1") print "eth1"; else print "eth0"}‘ |head -1) ;ifconfig |awk ‘{if(a) {split($0,b,"addr:| Bcast:");print b[2]} ;a=0}/‘"$NETCARD"‘/{a=1}‘ |head -1)"
sed -i -e"/PS1/ s#PS1=\"\[.*\\\.*\]#PS1=\"\\\[\\\e\[1;32m\\\]\[\\\u\@\\\[\\\e\[m\\\]\\\[\\\e\[1;36m\\\]\$\(NETCARD=\$\(ifconfig \|grep -B1 192.168 \|awk \‘/eth/ \{if \(\$1==\"eth1\"\) print \"eth1\"\; else print \"eth0\"\}\‘ \|head -1\) \;ifconfig \|awk \‘\{if\(a\) \{split\(\$0\,b\,\"addr\:\| Bcast\:\")\;print b\[2\]\} \;a=0\}/\‘\"\$NETCARD\"\‘/\{a=1\}\‘ \|head -1\)\\\[\\\e\[m\\\]\\\[\\\e\[1;32m\\\] \\\w\]\\\[\\\e\[m\\\]# " /etc/bashrc

sed -i "s/PROMPT_COMMAND=‘echo/PROMPT_COMMAND=‘‘; #‘echo/" /etc/bashrc
}

case $SYSVER in
4.6)
echo "The current system VER $SYSVER"
modify_bashrc
;;
5.4)
echo "The current system VER $SYSVER"
modify_bashrc
;;
*)
echo "The current system don‘t know $SYSVER"
modify_bashrc
;;
esac


echo "########execute $0 end...##############"

技术分享

 

一个shell脚本,让你的linux命令行酷炫起来

标签:==   $0   linux命令   命令   comm   grep   current   ifconf   roo   

原文地址:http://www.cnblogs.com/qinyujie/p/7049681.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!