On Sun, 7 Jun 2015 13:36:53 -0400, Robert A. Rosenberg wrote:

>At 09:46 -0500 on 06/07/2015, Paul Gilmartin wrote about Re: DFSORT -
>How to select last 8 bytes in variable length :
>
>>On Sun, 7 Jun 2015 22:28:01 +0900, Minoru Massaki wrote:
>>
>>>Hello
>>>
>>>There is a input file of variable length records.
>>>I want to insert the last 8 bytes of a record to front of the record as
>>>following sample. ...
>>>
>>Must it be DFSORT?  For example:
>>
>>508 $ cat last8; sh last8
>>#! /bin/sh -x
>>
>>echo "\
>>RECORD01X11AAAAAAAA
>>RECORD02Y2BBBBBBBB
>>RECORD03ZCCCCCCC
>>RECORD044A4444444DDDDDDDD
>>RECORD0555B55555555EEEEEEEE"  |
>>
>>sed 's/\(.*\)\(........\)/\2 \1/'
>>
>>AAAAAAAA RECORD01X11
>>BBBBBBBB RECORD02Y2
>>ZCCCCCCC RECORD03
>>DDDDDDDD RECORD044A4444444
>>EEEEEEEE RECORD0555B55555555
>>509 $
>>
>>Is it then possible to pipe the output of "sed" into SORTIN?
>>
>>-- gil
>
>While this may be a way of doing this your script has an error (if
>the sample output is accurate). The request was to append the last 8
>characters to the record while your sample moves it there (dropping
>these characters from the altered record).
>
Just add another \2 after\1.

But the OP also said this:
 "Record data before the last 8 bytes may contain x'00' thru x'FF' "

That would mean there could be end-of-line characters and hex 00 characters in 
a record, which would mean "sed" would not work.

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