CR/LF suggestion

Andrew Hertz hertz at geog.psu.edu
Wed Feb 10 21:31:11 EST 1993


Well I've never figured out how to strip off CR/LF characters
using sed or awk, however I was able to using dd - a file
conversion utility.  If you know the block size of the 
records you can strip off the CR/LF by specifying an output
block size 1 byte smaller.  For example, the data general
machines used by the USFS typically use a block size of 
1024 bytes with a CR/LF character appended.  To strip that
off, I used the following command where:
 if= the input file, of= the output file, 
 ibs= input block size, obs= output block size
 cbs= conversion block size, conv= conversion type

dd if=in.dem of=out.dem ibs=1025 obs=1024 cbs=1024 conv=block

If you don't know the block size, you might be able to 
deduce it using the command od - output dump utility.
For example:  od -a in.dem would output the dem file in.dem
a byte at a time interpreted as an ascii character - CR/LF
characters appear as nl (newline).  By comparing the byte 
addresses where the nl characters appear the block size can
be determined (the addresses are in octal)

Good luck,
Andrew Hertz
hertz at geog.psu.edu



More information about the grass-user mailing list