awk區(qū)間取值的例子
更新時間:2013年02月04日 18:28:05 作者:
awk區(qū)間取值的例子,匹配某一區(qū)間內(nèi)的值,有需要的朋友不妨參考下
有如下的文本內(nèi)容:
*********
123123
123123
*********
321321
321321
*********
456456
456456
*********
123123
123123
********
匹配123,取出******區(qū)間的內(nèi)容:
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.
*********
123123
123123
*********
321321
321321
*********
456456
456456
*********
123123
123123
********
匹配123,取出******區(qū)間的內(nèi)容:
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.
相關(guān)文章
Linux設(shè)置每晚定時備份Oracle數(shù)據(jù)表的操作命令
這篇文章主要介紹了Linux設(shè)置每晚定時備份Oracle數(shù)據(jù)表,本文通過腳本命令給大家介紹的非常詳細,對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下2022-12-12
Shell腳本中單引號(‘)和雙引號(“)的使用區(qū)別
這篇文章主要介紹了Shell腳本中單引號(‘)和雙引號(“)的使用區(qū)別,主要探討了變量在單引號和雙引號中的不同,需要的朋友可以參考下2014-06-06
Shell兩種for循環(huán)對應(yīng)實現(xiàn)方法解析
這篇文章主要介紹了Shell兩種for循環(huán)對應(yīng)實現(xiàn)方法解析,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下2020-08-08
一天一個shell命令 文本操作系列-linux dd使用教程
dd 是 Linux/UNIX 下的一個非常有用的命令,作用是用指定大小的塊拷貝一個文件,并在拷貝的同時進行指定的轉(zhuǎn)換2016-05-05

