View previous topic :: View next topic
|
Author |
Message |
pshongal
New User
Joined: 14 Jun 2012 Posts: 98 Location: India
|
|
|
|
I have a file as below. I want to copy only the "text" from the records. Since the position of text is random, how do I copy?
Input:
Code: |
1 1 xxx-xxx
2 1 nn-nn-nn
3 1 yy-y
4 2 xx-xx
5 2 mm-mm
|
Output:
Code: |
xxx-xxx
nn-nn-nn
yy-y
xx-xx
mm-mm
|
Thanks |
|
Back to top |
|
|
Joerg.Findeisen
Senior Member
Joined: 15 Aug 2015 Posts: 1335 Location: Bamberg, Germany
|
|
|
|
For the given sample data, use:
Code: |
OPTION COPY
INREC BUILD=(1,80,SQZ=(SHIFT=LEFT,PREBLANK=C'0123456789'))
END |
|
|
Back to top |
|
|
Joerg.Findeisen
Senior Member
Joined: 15 Aug 2015 Posts: 1335 Location: Bamberg, Germany
|
|
|
|
Alternatively, a PARSE on the third column helps. |
|
Back to top |
|
|
pshongal
New User
Joined: 14 Jun 2012 Posts: 98 Location: India
|
|
|
|
Thank you very much Joerg. I was not aware squeeze option in sort. It worked. |
|
Back to top |
|
|
Joerg.Findeisen
Senior Member
Joined: 15 Aug 2015 Posts: 1335 Location: Bamberg, Germany
|
|
|
|
The alternate option would be like this:
Code: |
OPTION COPY
INREC IFTHEN=(WHEN=INIT,
PARSE=(%=(STARTAT=NONBLANK,ENDBEFR=BLANKS,REPEAT=2),
%01=(STARTAT=NONBLANK,ENDBEFR=BLANKS,FIXLEN=80)),
BUILD=(%01))
END |
|
|
Back to top |
|
|
|