diff --git a/shell/backup/accountlog.sh b/shell/backup/accountlog.sh new file mode 100644 index 0000000..303013b --- /dev/null +++ b/shell/backup/accountlog.sh @@ -0,0 +1,72 @@ +# 网上流传的简单记录操作的脚本 +#vi /etc/profile.d/accountlog.sh +#chmod +x /etc/profile.d/accountlog.sh +#vi /etc/profile +#HISTTIMEFORMAT="%Y/%m/%d %H:%M:%S " +historyLog(){ + + logDir=/data/accountlog + + dateStamp=`date +"[%F %T]"` + + dateDir="`date +%Y`/`date +%m`/`date +%d`" + + curHistory=`history 1` + + user=`/usr/bin/whoami` + + realUserInfor=`/usr/bin/who -u am i|awk '{print $1,$2,$3"~"$4,$7}'` + + + + if [ ! -e $logDir ];then + + mkdir -p $logDir + + chmod 777 $logDir + + fi + + + + logDateDir=$logDir/$dateDir + + if [ ! -e $logDateDir ];then + + mkdir -p $logDateDir + + chmod -R 777 $logDir 2>/dev/null + + fi + + + + accountLogDir=$logDateDir/${user:=`hostname`} + + if [ ! -e $accountLogDir ];then + + mkdir -p $accountLogDir + + #chmod 777 $accountLogDir + + fi + + + + accountLogName=${user:=`hostname`}.his + + accountLog=$accountLogDir/$accountLogName + + if [ ! -e "$accountLog" ];then + + touch $accountLog + + #chmod 777 $accountLog + + fi + + echo "$realUserInfor $dateStamp =>$curHistory" >>$accountLog + +} + +export PROMPT_COMMAND=historyLog diff --git a/shell/sed/sed.sh b/shell/sed/sed.sh index 13f7a08..c59e1bf 100644 --- a/shell/sed/sed.sh +++ b/shell/sed/sed.sh @@ -5,6 +5,15 @@ ##robert yu ##centos 6鍜宑entos 7 +##鏌ユ枃浠朵粠32994鍒34871琛屽唴瀹 +sed -n '32994,34871p' config_file + +##鍒犻櫎鏂囦欢浠32994鍒34871琛屽唴瀹 +sed '32994,34871 d' config_file + +##鏇挎崲鏂囦欢涓璸erformance_schema鏀逛负performance_schema_bak +sed -i "s/performance_schema/performance_schema_bak/g" config_file + ##sed鍘婚櫎娉ㄩ噴琛 sed -i -c -e '/^#/d' config_file