On Mon, 1 Jun 2015 17:11:54 -0400, Shmuel Metz (Seymour J.) 
<shmuel+ibm-m...@patriot.net> wrote:

>In <0379604180364016.wa.bgodfrey.gzgmail....@listserv.ua.edu>, on
>05/29/2015
>   at 10:30 AM, Bill Godfrey <bgodfrey...@gmail.com> said:
>
>>I get identical results whether I use \n or $ in the OP's example. In
>>OMVS. I'm not addressing your question but rather the OP's example.
>
>Which OMVS facilities match \n to end of line (record) and which to
>LF? What do grep et al do about matching \n against legacy PS data
>sets, where there is a logical end of record?
>
When commands like "cat" and "cp" read legacy PS data sets as text, the results 
reflect this description of "reading text files" in the C/C++ Programming Guide:

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/CBCPG1C0/2.9.4.2

Where it says:

"For files opened in fixed text format, rightmost blanks are stripped off a 
record at input, and a new-line character is placed in the logical record."

That new-line character is hex 15.

So a 3-line data set of 80-byte records that look like this:

a
test
testing

will look like this in hex after being read by "cat"

cat "//test.cntl" | od -tx1 -An
    81  15  A3  85  A2  A3  15  A3  85  A2  A3  89  95  87  15

which is the same result as this command:

printf %b "a\ntest\ntesting\n" | od -tx1 -An
    81  15  A3  85  A2  A3  15  A3  85  A2  A3  89  95  87  15

The only facility with regular expressions that I have found that matches \n to 
end-of-line is in Perl. For example:

printf %b "a\ntest\ntesting\n" | perl -ne 'print if /test\n/'
test

printf %b "a\ntest\ntesting\n" | perl -ne 'print if /test$/'
test

The "grep" and "awk" commands don't match \n to end-of-line on omvs, or on 
linux for that matter.

The "grep" command can't read a legacy PS data set directly, but "awk" can.

awk '/test$/' "//test.cntl"
test

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