当前位置:网站首页>shell--第九章练习
shell--第九章练习
2022-08-01 10:14:00 【weixin_51808099】
1、获取根分区剩余大小
df -h | tail -1 | awk '{print $4}'
2、获取当前机器ip地址
ifconfig ens160 | head -2 | awk '{print $2}'| grep "^1"
3、统计出apache的access.log中访问量最多的5个IP
awk '{print $1}' | sort -n |unip -c | tail -5 /access.log
4、打印/etc/passwd中UID大于500的用户名和uid
awk -F : '$3>500{print $3}' /etc/passwd
5、/etc/passwd 中匹配包含root或net或ucp的任意行
awk -F : '/(root|net|ucp)/ {print $0}' /etc/passwd
6、处理以下文件内容,将域名取出并根据域名进行计数排序处理(百度搜狐面试题)
test.txt
http://www.baidu.com/index.html
http://www.baidu.com/1.html
http://post.baidu.com/index.html
http://mp3.baidu.com/index.html
http://www.baidu.com/3.html
http://post.baidu.com/2.html
awk -F / '{print $3}' test.txt | sort | uniq -c | sort -n
7、请打印出/etc/passwd 第一个域,并且在第一个域所有的内容前面加上“用户帐号:”
awk -F : '{print "用户账号:"$1}' /etc/passwd
8、请打印出/etc/passwd 第三个域和第四个域
awk -F : '{print $3 " " $4}' /etc/passwd
9、请打印第一域,并且打印头部信息为:这个是系统用户,打印尾部信息为:“================”
awk -F : 'BEGIN{print "这个是系统用户"}{print $1}END{print "================"}' /etc/passwd
10、请打印出第一域匹配daemon的信息.
awk -F : '$1=="daemon"' /etc/passwd
11、请将/etc/passwd 中的root替换成gongda,记住是临时替换输出屏幕看到效果即可.
awk -F: 'gsub(/root/,"gongda")' /etc/passwd
12、请匹配passwd最后一段域bash结尾的信息,有多少条
awk -F: '$NF~/bash$/{print NR}' /etc/passwd | wc -l
13、请同时匹配passwd文件中,带mail或bash的关键字的信息
awk -F: '/root|mail/' /etc/passwd
边栏推荐
- How to find out hidden computer software (how to clean up the computer software hidden)
- pve 删除虚拟机「建议收藏」
- MFC实现交通图导航系统
- 阿里腾讯面试一二
- Small application project works WeChat gourmet recipes applet graduation design of finished product (1) the development profile
- 小程序毕设作品之微信美食菜谱小程序毕业设计成品(2)小程序功能
- InputStream转成String
- Qt supports HEIC/HEIF format images
- Meeting OA (Upcoming Meetings & All Meetings)
- CTFshow,命令执行:web37
猜你喜欢

如何解决 chrome 浏览器标签过多无法查看到标题的情况

Opencv creates a window - cv.namedWindow()

The meaning and trigger conditions of gc

企业微信群:机器人定时提醒功能数据库配置化

SAP ABAP OData 服务如何支持 $orderby (排序)操作试读版

mysql在cmd的登录及数据库与表的基本操作

Explain / Desc execution plan analysis

Py之yellowbrick:yellowbrick的简介、安装、使用方法之详细攻略

Custom Types - Enums, Unions

How to Steal $100 Million from the Perfect Smart Contract
随机推荐
Pve delete virtual machine "for a collection"
自定义类型——枚举、联合
CTFshow,命令执行:web37
Mini Program Graduation Works WeChat Food Recipes Mini Program Graduation Design Finished Products (3) Background Functions
Dataset之mpg:mpg数据集的简介、下载、使用方法之详细攻略
Mysql索引相关的知识复盘一
ASP.NET Core 6 Framework Revealing Instance Demonstration [30]: Develop REST API with Routing
InputStream转成String
The first experience of Shengsi large model experience platform——Take the small model LeNet as an example
WPF 截图控件之绘制箭头(五)「仿微信」
PowerPC技术与市场杂谈
Custom Types - Enums, Unions
Qt 支持HEIC/HEIF格式图片
【cartographer ros】十: 延时和误差分析
JWT
基于CAP组件实现补偿事务与消息幂等性
CTFshow,命令执行:web34、35、36
如何从完美的智能合约中窃取 1 亿美元
使用KeyStore生成证书
Introduction and application of pointers