脚本之家,脚本语言编程技术及教程分享平台!
分类导航

Python|VBS|Ruby|Lua|perl|VBA|Golang|PowerShell|Erlang|autoit|Dos|bat|shell|

服务器之家 - 脚本之家 - shell - awk区间取值的例子

awk区间取值的例子

2022-12-12 11:14脚本之家 shell

awk区间取值的例子,匹配某一区间内的值,有需要的朋友不妨参考下

有如下的文本内容:
*********
123123
123123
*********
321321
321321
*********
456456
456456
*********
123123
123123
********

匹配123,取出******区间的内容:
awk -vRS="*+" '/123/{print RT$0}' file

说明:
RS The input record separator, by default a newline(\n).
RT The record terminator. Gawk sets RT to the input text that matched the character or regular expression specified by RS.

延伸 · 阅读

精彩推荐