How to remove line numbers via fromdsn

Discussion of Dovetailed Technologies Dataset Pipes tools
Post Reply
sctebnt
Posts: 30
Joined: Mon Nov 02, 2009 10:47 pm

How to remove line numbers via fromdsn

Post by sctebnt » Tue Sep 13, 2011 11:06 am

When using fromdsn on a ZOS file, where the ZOS file contains line numbers in positions 73 - 80 and may have NUMBER DISPLAY STD in the ZOS file profile, is there a way to have fromdsn remove these line numbers?

JohnMcKown
Posts: 39
Joined: Sat Nov 21, 2009 2:59 pm

Re: How to remove line numbers via fromdsn

Post by JohnMcKown » Thu Sep 15, 2011 10:57 am

I'm not aware of any. But it is rather simple if you are running UNIX.

fromdsn ...| sed 's/^(.{0,72}).*$/\1/' >output.file.columns.1.through.72

or

fromdsn ...|perl -n -e 'chomp;print substr($_,0,72)."\n";' >output.file.columns.1.through.72

or, simplest

fromdsn ... | cut -b 1-72 >output.file.columns.1.through.72

Now, in both examples, your output might contain trailing blanks. And it will remove anything beyond column 72, not just numbers. To eliminate trailing blanks:

fromdsn ... | perl -n -e 'chomp;s/^(.{0,72}).*$/$1/;s/ *$//;print "$_\n";' >output.file.columns.1.through.72.no.trailing.blanks

sctebnt
Posts: 30
Joined: Mon Nov 02, 2009 10:47 pm

Re: How to remove line numbers via fromdsn

Post by sctebnt » Tue Sep 20, 2011 11:40 pm

Thanks for the examples, I ended up using the following to only replace line numbers when there are 8 digits at the end of a record. This allows me to support files of any length containing line numbers. Note the -k arg to keep trailing blanks from your ISPF file cards, without this option a card ending in an expected numeric value would be removed from your card.

Code: Select all

fromdsn -k //DD:MYREF 2>>error.dat | perl -pi -e 's/\d{8}$/        /ogs' 2>>error.dat >myfile.dat

Post Reply