Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!mips!wdl1.wdl.loral.com!wdl50!mdm From: mdm@wdl50.wdl.loral.com (Mike D Marchionna) Newsgroups: comp.sys.next Subject: Re: Files created on IBM clones Message-ID: <1991Mar11.231427.8063@wdl1.wdl.loral.com> Date: 11 Mar 91 23:14:27 GMT References: <1991Mar11.155026.3504@ux1.cso.uiuc.edu> <1991Mar11.200319.8207@agate.berkeley.edu> Sender: news@wdl1.wdl.loral.com Organization: LORAL Western Development Labs Lines: 45 izumi@fugitive.berkeley.edu (Izumi Ohzawa) writes: >In article <1991Mar11.155026.3504@ux1.cso.uiuc.edu> ceblair@ux1.cso.uiuc.edu (Charles Blair) writes: >> >> I created a C program using the editor supplied by Turbo C 2.0 on >>an IBM clone, copied this to a diskette, then read it into the NeXt. >>Something went wrong somewhere along the way. The file seemed to be >>missing the last line and had what seemed to be invisible characters >>which were also messing things up. The file also looked a little >>different when I looked at it using (1) ed called from Terminal >>(2) Write Now. >You are looking at possibly two things. >One is a CR (0x0A) char at the end of each line, and the other >is a CTL-Z character at the end of the file. >Unix (NeXT) text files use LF (0x0D) as the end-of-line marker, >while MSDOS uses CR LF pair to indicate the same. >You will see CR char as "^M" in 'vi'. >CTL-Z is no longer needed for MSDOS, but a lot of editors still >put it in at the end of the file. >I know that cc on NeXT chokes on CTL-Z char, and may be other >things too. >Write a filter program which removes all control characters >with the exception of LF, TAB, FF. It's a 5-line program. >And process all files imported from MS-DOS platforms. >Does /NextApps/Edit have an option of displaying control >characters in a text file? That is sourly needed to see >this kind of problems with text files. Or you could use the program UNIX already provides for this sort of thing called 'tr'. What, you didn't intuitively know that tr stood for translate characters. Well neither did I. This here little command will delete all CR and CTRL-Z characters from "infile" and write the remaining characters to "outfile". tr -d '\015\032' < infile > outfile -- +--------------||--##--%%--@@------+--------------------------------------+ |El-Rayo-X-----||--##--%%--@@----->| Brain and brain! What is brain! | |El-Rayo-X-----||--##--%%--@@----->| --Star Trek (Spock's Brain) | +--------------||--##--%%--@@------+--------------------------------------+