#///////////////////////////////////////////////////////////////////////# #/ # #/ Welcome Browes: http://www.kinggoo.com # #/ Find Oracle 11g R1 Required Packages # #/ Add To temp File Query # #///////////////////////////////////////////////////////////////////////# #/ Url:http://www.kinggoo.com/archives/chengxu-shell-rpm-qa-grep.html # #///////////////////////////////////////////////////////////////////////#
#!/bin/bash rm -fr rpm-qa.log > /dev/null rm -fr cat_temp > /dev/null clear printf "\n" echo -e "\e[1;49;36mMy Name is\e[0m \e[1;5;49;32mKingGoo\e[0m! " echo -e "\e[1;49;36mWebSite:\e[0m \e[49;37mhttp://www.kinggoo.com \e[0m" printf "\n" #Optimize Speed rpm -qa > rpm-qa.temp #cat temp.txt |cut -d ‘-‘ -f 1 > cat_temp awk -F ‘-‘ ‘{printf $1}{ printf "-"}{ printf $2}{printf "-"}{printf $3"\n"}’ temp.txt > cat_temp l=`cat cat_temp |wc -l` i=1 while [[ "$i" -le "$l" ]];do H_ZHI=`awk -F ‘-‘ ‘NR==’$i'{ printf $1 }’ cat_temp` test -z "$H_ZHI" Statu_TEST_H_ZHI=$? if (( $Statu_TEST_H_ZHI > 0 ));then H_ZHI1=`awk -F ‘-‘ ‘NR==’$i'{ printf $2 }’ cat_temp` test -z "$H_ZHI1" Statu_TEST_H_ZHI1=$? if (( $Statu_TEST_H_ZHI1 > 0 ));then CUT_H_ZHI1=`echo $H_ZHI1|cut -c 1` expr $CUT_H_ZHI1 + 10 > /dev/null 2> /dev/null Statu_CUT_H_ZHI1=$? if (( $Statu_CUT_H_ZHI1 > 0 ));then CUT_H_ZHI1=-$CUT_H_ZHI1.* H_ZHI2=`awk -F ‘-‘ ‘NR==’$i'{ printf $3}’ cat_temp` test -z "$H_ZHI2" Statu_TEST_H_ZHI2=$? if (( $Statu_TEST_H_ZHI2 > 0 ));then CUT_H_ZHI2=`echo $H_ZHI2|cut -c 1` expr $CUT_H_ZHI2 + 10 > /dev/null 2> /dev/null Statu_CUT_H_ZHI2=$? if (( $Statu_CUT_H_ZHI2 > 0 )) ; then CUT_H_ZHI2=-$CUT_H_ZHI2.* else CUT_H_ZHI2="" echo -n . fi else CUT_H_ZHI2="" fi else CUT_H_ZHI1="" CUT_H_ZHI2="" echo -e -n "\e[5;32m.\e[0m". fi else CUT_H_ZHI1="" CUT_H_ZHI2="" fi #Delete Every "rpm -qa" Query. # rpm -qa |grep -i "^$H_ZHI$CUT_H_ZHI1$CUT_H_ZHI2" 1> /dev/null #Query "rpm -qa > rpm-qa.temp" File. grep -i "^$H_ZHI$CUT_H_ZHI1$CUT_H_ZHI2" rpm-qa.temp 1> /dev/null Statu0=$? if (( $Statu0 > 0 ));then ERROR=`awk ‘NR==’$i'{printf $1 }’ temp.txt` echo "$ERROR" >> rpm-qa.log fi fi (( i++ )) done clear printf "\n" echo -e "\e[49;36mMy Name is\e[0m \e[1;5;49;32mKingGoo\e[0m! " echo -e "\e[49;36mWebSite:\e[0m \e[49;37mhttp://www.kinggoo.com \e[0m" echo " " test -f rpm-qa.log Statu1="$?" if [ $Statu1 -eq "0" ];then echo -e "\e[1;5;41;7mPlease, Install Below Package\e[0m" cat rpm-qa.log rm -fr rpm-qa.log > /dev/null else echo -e "\e[1;42mAlready full installation\e[0m" fi
printf "\n" rm -fr rpm-qa.temp > /dev/null rm -fr cat_temp > /dev/null exit
|
like me
Thanks!
I hope it can help you.
I also like.
博主的文章很好,学习了,欢迎回访
哈哈谢谢啦~
希望有帮助吧~
去你的website了