[Novalug] Reading a fixed length text file with no record separator

Jon LaBadie novalugml@jgcomp.com
Tue Oct 18 23:02:01 EDT 2016


On Tue, Oct 18, 2016 at 03:41:14PM +0000, Ide, Jim J. - US via Novalug wrote:
> I tried using ‘dd’ as RSK suggested, and it works fine.

ditto

> 
> The reason I used ‘fold’ is because I am using Windows 7 for this task,
> and the version of ‘dd’ that I have available appends only \n to each record,
> but I wanted both \r\n to terminate each record. For some reason,
> the version of ‘fold’ ported to Windows appends \r\n to the end of
> each record, not just \n as I would have expected.
> 
> ‘fold’ solved my problem, so that’s what I’m going with.
> 

I think the difference is that fold is a "text" tool while dd operates
on bytes/records.  As a text tool, fold would add whatever is the
appropriate End Of Line marker for the OS it is compiled for.  I'm
guessing the "conv=unblock" option of dd is documented to add a
newline character rather than an end of line marker.  To do other-
wise would break its documented action.

If necessary to use the dd solution, adding the CR would be easy.

> 
> From: greg pryzby [mailto:greg@pryzby.org]
> Sent: Tuesday, October 18, 2016 11:19 AM
> To: Ide, Jim J. - US; William Sutton; Jared Scott
> Cc: novalug@firemountain.net
> Subject: Re: [Novalug] Reading a fixed length text file with no record separator
> 
> 
> If you could try RSKs suggestion I would like to know of it worked and appreciate.
> 

-- 
Jon H. LaBadie                  novalugml@jgcomp.com
 11226 South Shore Rd		(703) 787-0688 (H)
 Reston, VA  20190		(703) 935-6720 (C)



More information about the Novalug mailing list