首页 > 代码库 > shell初学

shell初学

超简单的一段shell代码,查看电脑属性,删除无效安装包,查看天气。FYI 

#!/bin/bashecho -e \necho "Hello,`whoami`"echo "-----------------------------------------------------------------------"echo "Now time is:`date`"#wheather infoif [ -e "101020100.html" ];thenrm -f 101020100.htmlwget http://www.weather.com.cn/data/cityinfo/101020100.html -qelsewget http://www.weather.com.cn/data/cityinfo/101020100.html -qfivar=$(cat 101020100.html)#echo "天气信息:" $varecho $var | awk -F " {print $6 "   " $14 " ~ " $18 "   " $22 " [ " $34 " ] "}echo "-----------------------------------------------------------------------"echo -e \necho "-----------------------------------------------------------------------"echo -e "The PC Info:"uname -aecho "-----------------------------------------------------------------------"echo -e \necho "-----------------------------------------------------------------------"echo Shall you clean trash?echo "Please input (y\n)"read charif [ $char == y ];then#delete useless install packagesudo apt-get autocleansudo apt-get cleansudo apt-get autoremoveelseecho "You selected no"fiecho "-----------------------------------------------------------------------"echo "Press anykey to exit..."

 

shell初学