当前位置:网站首页>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
边栏推荐
- July 31, 2022 -- Take your first steps with C# -- Use arrays and foreach statements in C# to store and iterate through sequences of data
- 使用ESP32驱动QMA7981读取三轴加速度(带例程)
- Taobao commodity details and details on taobao, senior upgrade version of the API
- Introduction to STM32 development Introduce IIC bus, read and write AT24C02 (EEPROM) (using analog timing)
- Push the local project to the remote repository
- ClickHouse多种安装方式
- 7/31 训练日志
- 昇思大模型体验平台初体验——以小模型LeNet为例
- Mini Program Graduation Works WeChat Food Recipes Mini Program Graduation Design Finished Products (2) Mini Program Functions
- 小程序毕设作品之微信美食菜谱小程序毕业设计成品(2)小程序功能
猜你喜欢

CTFshow,命令执行:web31

Android 安全与防护策略

Mini Program Graduation Works WeChat Food Recipes Mini Program Graduation Design Finished Products (2) Mini Program Functions

redis

CTFshow,命令执行:web34、35、36

Endorsed in 2022 years inventory | product base, science and technology, guangzhou automobile group striding forward

How programmers learn open source projects, this article tells you

Three chess (C language implementation)

ClickHouse入门介绍与其特性

VS“无法查找或打开PDB文件”是怎么回事?如何解决
随机推荐
URL.createObjectURL、URL.revokeObjectURL、Uint8Array、Blob使用详解
Mini Program Graduation Works WeChat Food Recipes Mini Program Graduation Design Finished Products (3) Background Functions
如何在IntellJ IDEA中批量修改文件换行符
记一次 .NET 某智慧物流WCS系统CPU爆高分析
解决new Thread().Start导致高并发CPU 100%的问题
SkiaSharp's WPF self-painted five-ring bouncing ball (case version)
【cartographer ros】十: 延时和误差分析
shell脚本------条件测试 if语句和case分支语句
Guangyu Mingdao was selected into the list of pilot demonstration projects for the development of digital economy industry in Chongqing in 2022
ASP.NET Core 6 Framework Revealing Instance Demonstration [30]: Develop REST API with Routing
redis
How to find out hidden computer software (how to clean up the computer software hidden)
Explain / Desc execution plan analysis
微信公众号授权登录后报redirect_uri参数错误的问题
使用ESP32驱动QMA7981读取三轴加速度(带例程)
WPF 截图控件之绘制箭头(五)「仿微信」
回归预测 | MATLAB实现RNN循环神经网络多输入单输出数据预测
Yang Hui Triangle (C language implementation)
Browser shortcut keys
CTFshow,命令执行:web32