shell初学
2024-10-19 04:34:50
超简单的一段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 .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 .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..."
最新文章
- hibernate学习(7)——HQL查询
- s5pv210 cpu运行debian
- CentOS 7 安装 MySQL Database
- CNC Fanuc 设备数据采集
- (转)JS浮动窗口(随浏览器滚动而滚动)
- OpenJudge/Poj 1316 Self Numbers
- solrj6.2异常--Expected mime type application/octet-stream but got text/html.
- 五子棋Web版的开发(二)--整合Spring4.3+hibernate4+Struts2.3
- iOS Development: Proper Use of initWithNibName:bundle: Affects UITableViewController
- hdu 2838 Cow Sorting
- Good Time 冲刺 二
- 【JavaScript 6连载】一、关于对象(访问)
- MVC 控制器中传递dynamic(对象) 给视图
- google浏览器mac上跨域问题解决
- 贴心的vs 备注提醒功能
- Transformer-view java实体 转换视图 Lists.transform
- Redis hash数据结构
- numpy数组与python的list互转,然后用json写入文件与c交互
- AngularCSS 的引入: CSS On-Demand for AngularJS
- Null Coalescing Operator