当前位置:网站首页>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
边栏推荐
- CTFshow,命令执行:web32
- 微信公众号授权登录后报redirect_uri参数错误的问题
- C#/VB.NET convert PPT or PPTX to image
- 回归预测 | MATLAB实现RNN循环神经网络多输入单输出数据预测
- notes....
- 小程序毕设作品之微信美食菜谱小程序毕业设计成品(3)后台功能
- 【cartographer ros】十: 延时和误差分析
- 如何解决 chrome 浏览器标签过多无法查看到标题的情况
- Qt supports HEIC/HEIF format images
- Visualization - Superset installation and deployment
猜你喜欢
.NET性能优化-使用SourceGenerator-Logger记录日志
什么是步进电机?40张图带你了解!
AC与瘦AP的WLAN组网实验
VS“无法查找或打开PDB文件”是怎么回事?如何解决
ClickHouse入门介绍与其特性
周鸿祎称微软抄袭 360 安全模式后发文否认;英特尔CEO基辛格回应市值被AMD超越:股价下跌是咎由自取|极客头条
Mini Program Graduation Works WeChat Food Recipes Mini Program Graduation Design Finished Products (3) Background Functions
Mini Program Graduation Works WeChat Food Recipes Mini Program Graduation Design Finished Products (2) Mini Program Functions
MacOS下postgresql(pgsql)数据库密码为什么不需要填写或可以乱填写
Mini Program Graduation Works WeChat Food Recipes Mini Program Graduation Design Finished Products (4) Opening Report
随机推荐
[Software Architecture Mode] The difference between MVVM mode and MVC mode
小程序毕设作品之微信美食菜谱小程序毕业设计成品(2)小程序功能
我是如何保护 70000 ETH 并赢得 600 万漏洞赏金的
How to find out hidden computer software (how to clean up the computer software hidden)
线上问题排查常用命令,总结太全了,建议收藏!!
retired paddling
EasyRecovery热门免费数据检测修复软件
Dataset之mpg:mpg数据集的简介、下载、使用方法之详细攻略
回归预测 | MATLAB实现RNN循环神经网络多输入单输出数据预测
Push the local project to the remote repository
WPF 截图控件之绘制箭头(五)「仿微信」
Custom Types - Enums, Unions
Mini Program Graduation Works WeChat Food Recipes Mini Program Graduation Design Finished Products (2) Mini Program Functions
退役划水
小程序毕设作品之微信美食菜谱小程序毕业设计成品(3)后台功能
企业微信群:机器人定时提醒功能数据库配置化
ASP.NET Core 6 Framework Revealing Instance Demonstration [30]: Develop REST API with Routing
MFC implementation road map navigation system
Taobao commodity details and details on taobao, senior upgrade version of the API
RK3399平台开发系列讲解(内核入门篇)1.52、printk函数分析 - 其函数调用时候会关闭中断