Re: Take command line arguments to generate an awk script

Grant Taylor <[email protected]> Sat, 24 Nov 2018 23:30:47 -0700
Newsgroups gmane.comp.gnu.m4.general
Organization TNet Consulting
Message-ID <[email protected]>
On 11/24/18 10:03 AM, Peng Yu wrote:
> Hi,

Hi,

> I'd like to generate the following awk script, where an array of number 
> (such as 1,3 in the following example) should be taken from the command 
> line. I am not familiar with m4 to make this work especially for an 
> array in the command line argument.

I think you will need to define a macro on the command line and then use 
it in the m4 file.

m4 --define=MACRO=value example.m4

--8<--example.m4--8<--
You passed "MACRO" as the value to M`'ACRO.
-->8-->8-->8-->8-->8--

> Could anybody help show me a working m4 example to generate an awk script 
> like this? Thanks.

I don't understand enough about your request to be able to interpret 
your needs.  Specifically:

  · I don't know if the number of command line parameters is variable or 
fixed.
  · I don't know if or how the AWK file changes based on what is passed 
to m4.
  · I would like to see hypothetical input and desired output of both m4 
and AWK.



-- 
Grant. . . .
unix || die
smime.p7s (application/pkcs7-signature, 3.9 KB) - not displayed