码迷,mamicode.com
首页 > 其他好文 > 详细

shell初学

时间:2014-09-21 18:26:40      阅读:187      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   ar   strong   div   sp   log   

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

#!/bin/bash
echo -e \n
echo "Hello,`whoami`"
echo "-----------------------------------------------------------------------"
echo "Now time is:`date`"
#wheather info
if [ -e "101020100.html" ];then
rm -f 101020100.html
wget http://www.weather.com.cn/data/cityinfo/101020100.html -q
else
wget http://www.weather.com.cn/data/cityinfo/101020100.html -q
fi
var=$(cat 101020100.html)
#echo "天气信息:" $var
echo $var | awk -F " {print $6 "   " $14 " ~ " $18 "   " $22 " [ " $34 " ] "}
echo "-----------------------------------------------------------------------"
echo -e \n
echo "-----------------------------------------------------------------------"
echo -e "The PC Info:"
uname -a
echo "-----------------------------------------------------------------------"
echo -e \n
echo "-----------------------------------------------------------------------"
echo Shall you clean trash?
echo "Please input (y\n)"
read char
if [ $char == y ];then
#delete useless install package
sudo apt-get autoclean
sudo apt-get clean
sudo apt-get autoremove
else
echo "You selected no"
fi
echo "-----------------------------------------------------------------------"
echo "Press anykey to exit..."

 

shell初学

标签:style   blog   http   color   ar   strong   div   sp   log   

原文地址:http://www.cnblogs.com/Tiago/p/3984657.html

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