[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Printing sections from files with sed
From: |
alex xmb ratchev |
Subject: |
Re: Printing sections from files with sed |
Date: |
Tue, 31 Jan 2023 08:02:23 +0100 |
try sed -r for more power regex mode
else .. use gawk
just ideas
/microsuxx
On Tue, Jan 31, 2023, 8:00 AM Hans Lonsdale <hanslonsdale@mailfence.com>
wrote:
> I want to print lines according to the following description
>
> ## FM [TOBIN]
> ## Some text
> ## More text
> ## END OF FM [TOBIN]
>
> I provide
>
> faml="FM"
> asmb="TOBIN"
>
> Here I set the matching patterns and call sed
>
>
> pn_ere='^[[:space:]]*([#;!]+|@c|//)[[:space:]]'
> 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
> }" "$filename"
>
> I get the error
>
> sed: -e expression #1, char 27: unknown command: `/'
>
>
> Initially thought the problem could be that either the vars are
> misspelled, or for some
> other reason one or both don't have values.
>
> But checking things again did not show any misspelled vars or empty values,
>
>
>
>
> --
> Sent with https://mailfence.com
> Secure and private email
>
>