sed -n ‘/root/,/test/p’ /etc/passwd
打印 /etc/passwd 中第8行开始,到含有 /sbin/nologin 的内容的行结束的内容
sed -n ‘8,//sbin/nologin/p’ /etc/passwd
打印 /etc/passwd 中第一个包含 /bin/bash 内容的行开始,到第5行结束的内容
sed -n ‘//bin/bash/,5p’ /etc/passwd
[](
)脚本练习
需求描述
处理一个类似MYSQL配置文件 my.cnf的文本,示例如下;
编写脚本实现以下功能:输出文件有几个段,并且针对每个段可统计配置参数总个数
my.cnf
文件内容如下
this is read by the standalone daemon and embedded servers
[client]
port=3306
socket=/tmp/mysql.socket
#ThisSegmentForserver
[server]
innodb_buffer_pool_size=91750M
innodb_buffer_pool_instances=8
innodb_buffer_pool_load_at_startup=1
innodb_buffer_pool_dump_at_shutdown=1
innodb_data_file_path=ibdata1:1G:autoextend
innodb_f