From adfdf75cb776752a169ec75fb1b381e987c13d09 Mon Sep 17 00:00:00 2001 From: Igor Chubin Date: Mon, 29 Aug 2022 09:32:32 +0200 Subject: [PATCH] Add: awk paragraph search, separated output --- sheets/awk | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sheets/awk b/sheets/awk index 72ab572..1a87950 100644 --- a/sheets/awk +++ b/sheets/awk @@ -47,8 +47,13 @@ awk -v RS='' ' printf '1 2 3' | awk 'BEGIN {OFS=":"}; {print $1,$2,$3}' # Search paragraph for the given REGEX match. +# Paragraphs will be collapsed together. awk -v RS='' '/42B/' file +# Search paragraph for the given REGEX match. +# Paragraphs will be separated with a new line. +awk -v RS= ORS='\n\n' '/42B/' file + # Display only first field in text taken from STDIN. echo 'Field_1 Field_2 Field_3' | awk '{print $1}' # Note that in this case, you're far better off using cut(1).