(1)读取文件最后一行:sed -n '$p' filename,如:sed -n '$p' test.log
(2)使用“后向引用”截取字符串:sed 's/[正则表达式A]\([正则表达式B]\)/\1/g' filename,如:
运行:sed 's/.*\(love[0-9]*\)able/\1/g' test.log (test.log的内容为:“oh oh love123able”)
结果为: love123
Powered by: 博客园 Copyright © 2024 Bruce Zhang Powered by .NET 9.0 on Kubernetes