help-bash
[Top][All Lists]
Advanced

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

Re: Printing TITLE, SUBTITLE, and KEYWORDS


From: Greg Wooledge
Subject: Re: Printing TITLE, SUBTITLE, and KEYWORDS
Date: Fri, 3 Feb 2023 12:55:29 -0500

On Fri, Feb 03, 2023 at 10:25:25AM -0600, Dennis Williamson wrote:
> On Fri, Feb 3, 2023, 9:34 AM Hans Lonsdale <hanslonsdale@mailfence.com>
> wrote:
> 
> > I have changed to using awk as the way to print sections defined by the
> > following structure
> >
> > ## NFAML [NASMB] KEYWORDS
> > ## BODY (can include empty lines)
> > ## END OF NFAML [NASMB]
> >
> > Am trying to print TITLE, SUBTITLE and the KEYWORDS array, but not getting
> > them printed.

The question keeps changing.  In the previous iteration, you said any
lines that did not begin with ## should be treated as the end of the
section, because sometimes the ## END OF ... section footer is missing.

Now, suddenly, there can be blank lines in the section body.

What are "TITLE" and "SUBTITLE"?

What "KEYWORDS array" are you talking about?  All I see is the string
KEYWORDS on the header line.  Is the portion of the header which follows
the ] character supposed to be parsed in some way?

It's pretty much impossible for anyone to help you if we can't pin down
the actual requirements.

> >     pn_ere='^[[:space:]]*([#;!]+|@c|//)[[:space:]]+'

That does not AT ALL match the sample inputs you have been providing.
That's the main problem here.  You're working with inputs that only
you can see.

If you're going to inject your strings into regexes, then you need to
"escape" them as I showed in a previous message.

It sounds like you're definitely going to do this, for reasons that
will never be clearly explained (perhaps they can be inferred by reverse
engineering your regexes).  So be it.  Just make sure you do it correctly.

> AWK isn't Bash. Please take your questions to an AWK or other list.

I'd say this is reasonably on-topic.  Especially since he'll need to
use bash to prepare the input strings for injection into the awk regex
variables.

Using awk within a bash script -- even if the awk portion ends up being
90% of the script -- is still a reasonable thing to discuss on help-bash
in my opinion.



reply via email to

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