On Tue, 2 Jun 2015 03:17:35 -0500, Paul Gilmartin wrote:

>On Mon, 1 Jun 2015 22:18:20 -0500, Bill Godfrey wrote:
>>
>>The "grep" and "awk" commands don't match \n to end-of-line on omvs, or on 
>>linux for that matter.
>>
>"awk" certainly does.  To wit:
>user@OS/390.24.00: cat awknl                                                   
>#! /bin/sh -x
>
>awk 'BEGIN {
>    String = "First line\nSecond line.\n"
>
>    # Show that "\n" is a line end.
>    printf( "%s", String )
>
>    # show that "\n" matches line end.
>    print( match( String, "\n" ) )
>}'
>user@OS/390.24.00: sh awknl
>First line
>Second line.
>11
>user@OS/390.24.00: 
>
I was only referring to \n in the pattern used in awk's general "pattern 
{action}" syntax, where the pattern
is matched against text being read. I should have qualified my statement.

It's important to note that in your awk example and my Perl example
the \n is not being treated as an anchor in the regex pattern, like $ would be.

You could change "\n" to "\n$" in the last print statement, and the result 
would be 24 instead of 11.

I'm sure you know all of this already. I'm just mentioning it for anyone who 
might not.

Bill

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

Reply via email to