help-bash
[Top][All Lists]
Advanced

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

Re: Stop printing when non-comment lines are reached


From: Hans Lonsdale
Subject: Re: Stop printing when non-comment lines are reached
Date: Thu, 2 Feb 2023 15:06:12 +0100 (CET)


> ----------------------------------------
> From: alex xmb ratchev <fxmbsw7@gmail.com>
> Date: Feb 2, 2023, 8:42:02 PM
> To: Hans Lonsdale <hanslonsdale@mailfence.com>
> Cc: Help Bash <help-bash@gnu.org>
> Subject: Re: Stop printing when non-comment lines are reached
> 
> 
> just wanna say , /beginmatch/ , /endmatch/ .. works also in awk

I shall work on that instead,
 
> On Wed, Feb 1, 2023, 7:20 PM Hans Lonsdale <hanslonsdale@mailfence.com>
> wrote:
> 
> > I am printing between sections of the following form
> >
> > ---------
> > ## FAML [ASMB] keyword,keyword
> >
> > ## Some text
> >
> > ## END OF FAML [ASMB]
> > ---------
> >
> > I have encountered a problem that occurs when "## END OF FAML [ASMB]" is
> > not reached.
> > I want to stop as soon as lines not starting with comment characters "##"
> > are encountered.
> >
> > For instance, I want to stop upon reaching "Some code" even though it did
> > not find
> > "## END OF FAML [ASMB]" because the line does not start with "##".
> >
> > ---------
> > ## FAML [ASMB] keyword,keyword
> >
> > ## Some text
> >
> > ## End OF FAL
> >
> > Some code
> > --------
> >
> > This is the implementation
> >
> >     spc='[[:space:]]*'
> >     gph="[[:graph:]]+"
> >     cmt='\/\/'
> >     ebl='\['
> >     ebr='\]'
> >
> >     local pn_ere="^[[:space:]]*([#;!]+|@c|${cmt})[[:space:]]+"
> >     local kys="(([^,]+)(,[^,]+)*)?"
> >
> >     nfaml=${faml:-"[[:graph:]]+"}
> >     nasmb=${asmb:-"[[:graph:]]+"}
> >
> >     beg_ere="${pn_ere}${nfaml} ${ebl}${nasmb}${ebr}${spc}${kys}$"
> >     end_ere="${pn_ere}END OF ${nfaml} ${ebl}${nasmb}${ebr}${spc}$"
> >
> >     sed -E -n "/$beg_ere/,/$end_ere/ {
> >          /$end_ere/z; s/$pn_ere// ; p
> >       }" "$filename"
> >
> >
> >
> > --
> > Sent with https://mailfence.com
> > Secure and private email
> >
> >


-- 
Sent with https://mailfence.com  
Secure and private email



reply via email to

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