help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Printing sections from files with sed


From: Kerin Millar
Subject: Re: Printing sections from files with sed
Date: Tue, 31 Jan 2023 07:18:52 +0000

On Tue, 31 Jan 2023 07:49:02 +0100 (CET)
Hans Lonsdale <hanslonsdale@mailfence.com> wrote:

> Here I set the matching patterns and call sed 
> 
> 
>       pn_ere='^[[:space:]]*([#;!]+|@c|//)[[:space:]]'

This contains unescaped slashes.

>       beg_re="${pn_ere}${faml} \[${asmb}\][[:space:]]*$"
>       end_re="${pn_ere}END OF ${faml} \[${asmb}\][[:space:]]*$"
> 
>       sed -n "/$beg_re/,/$end_re/ {
>           /$beg_re/d ; /$end_re/z; s/${pn_ere}// ; p

The s command here is using the slash as a delimiter.

Additionally, sed expects BREs unless given the -E option.

-- 
Kerin Millar



reply via email to

[Prev in Thread] Current Thread [Next in Thread]