TCLUG Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [TCLUG:1906] Shell Script Question -- CR/LF



On Fri, 23 Oct 1998, Luke Francl wrote:

> Hi All.  I work in a Windows 95 environment making and modifying HTML
> documents to go on a Unix server. This of course means I am plauged with
> the CR/LF nonsense constantly. Whenever I download a page to work on
> offline, Windows goes and adds another ^M to the end of the line --
> after several edits there can be a page of returns between every line of
> text. I have tried to keep this crap to a minimum by saving files in
> "unix" format in Homesite 3.0 (our development tool), but that doesn't
> completely eliminate the problem.

Yep. What you need to do is to somehow get a Macintosh to run BBEdit,
whose Save As Unix works correctly. It does a number of other things
correctly, as well. Even an old $100 Mac will work for this.

But that's just me. :)

> Also, our unix sysadmin is well...a moron, so there are no real tools
> installed on the server (no X, no emacs, not even pico...hell, less
> isn't even installed), and no ability to install them myself. Vi is the
> only editor I have avalible. 

You have write permission in your home directory, so just install what you
need in ~/bin and add ~/bin to your PATH.

> > Just to clarify, (this list has had this discussion before I think).  A
> > few ways to do this quickly:  in vi, :%s/[^L-^N]//g converts CR/LF to
> > just LF quite nicely.  There is also a dos2unix command that does this
> > (if my memory serves me correctly).  tr also works if invoked properly.
> 
> But what I would like to do is write a shell script to remove the ^M
> from every file in a directory.

I don't know about 'tr', but that 'vi' command is really an 'ex' command,
which you can run in a script ('ex' is subsumed within 'vi'). 'man ex' to
see what I mean.

Actually you could probably call 'vi' from with in a script as well, but I
have no idea how to do that. I'm niether a script guy nor a 'vi' guy. :)

The real solution is to learn 'vi' well, or install Emacs in your ~ and
learn it well, and avoid editing your files locally altogether. You'll be
much happier. That's what I did at my old job, where I had the same
problems.

Good luck and hth. :)

_____________________________________________________________________________
Christopher Reid Palmer : jaymz@acm.cs.umn.edu : innerFire on IRC (EFNet)

Free Software Special Interest Group : acm.cs.umn.edu/~jaymz/sigfs/