Dear All,
Thanks very much for the overwhelming number of responses. Needless to say,
this looks to be one of the oldest issues around. I got tons of different
(similar in concept) solutions, and I've taken a few minutes to acknowledge
everyone and their lines of solution. For me, a vi fan, the clue was to get ^M
by typing Ctrl-V-Ctrl-M.
thanks all.
Sauri
First: Original Posting, then summary (which is very long):
*********************************************************************
hi folks,
when one transfers text files from windows to unix systems, carriage returns
get appended at the end of lines as ^M character. I would like to remove this.
Is there some simple shell command? (I do search and replace operations on
various editors...)
thanks a lot..
-sauri
*******************************************************************
Howard Arnold arnoldh_at_celerent.com
"Hajnik Ferenc" FHajnik_at_suzuki.hu
"Dewhurst, Cy" cy.dewhurst_at_rbch-tr.swest.nhs.uk
"Pat Charron" charron_at_zk3.dec.com
"Kraft, Wolfram" Kraft.Wolfram_at_erdoelchemie.de
"Binkley Robert - rbinkl" Robert.Binkley_at_acxiom.com
Lawrie Smith lawrie.smith_at_capita.co.uk
Using VI or sed you can do a g/ ^M/s///g to get rid of the control M's (^M).
The ^M is typed by doing Ctrl-V-Ctrl-M. è This was the clue I was looking for.
Xavier Mertens xavier_at_be.wanadoo.com
Robert M Lang lang_at_isis.mit.edu
"Moore, Ric" Ric.Moore_at_msfc.nasa.gov
Jason Neil" jason_neil_at_yahoo.com
"Phil Farrell" farrell_at_pangea.Stanford.EDU
"Prasad, Sreenivasa" sreenivasa.prasad_at_digital.com
"Bob Marcan" bob.marcan_at_aster.si
Suggested the use of the tr command
cat <file> | tr -d "^M" > <newfile>
either as
cat inputfilename | tr -d "\015" > outputfilename
(different ways of representing "^M")
"Lucio Chiappetti" lucio_at_ifctr.mi.cnr.it
had a detailed answer, and pointed out that this occurs only when one shares
files, rather than transfers them. So using an ftp or other ascii transfer
method shouldn't cause this, but sharing causes the problem. You are right. We
use nfs share between the machines.
I got a few scripts on the lines of: (using troff, perl etc)
prompt > type /scriptdir/removecr
#!/bin/csh -f
foreach i ($argv)
tr -d '\015' < $i > temp.temp
mv -i temp.temp $i
end
prompt > type /scriptdir/unix2dos [to add the CR]
#/bin/csh -f
sed -e 's/$/^M/' $1 > $2
Mark Bowman" mb301_at_hotmail.com also suggested using transfer methods rather
than share.
http://www.ipswitch.com/Products/WS_FTP/index.html à get WSFtp from them.
"Michael A. Crowley" mcrowley_at_MtHolyoke.edu suggested downloading ftp software
fromm ftp.trentu.ca
shortest solution:
"Gavin Kreuiter" gavin_at_transactive.usko.com
The easiest is col:
col <winfile >unixfile
"John Venier" venier_at_odin.mdacc.tmc.edu
"Chris Ruhnke" ruhnke_at_us.ibm.com
Peter Stern Peter.Stern_at_weizmann.ac.il
"Bård_Tesaker" bt_at_chembio.ntnu.no
Michael Breen" mike_at_machinerebel.com
"Kevin Binda" bindak_at_brandonRHA.mb.ca
"Cathy Chandra" <cathy_at_atlas.otago.ac.nz>
suggested perl scripts such as
perl -p -i.dos -e 's/\r//g;' file
and
#! /usr/bin/perl -pi.dosbak
s/\r\n$/\n
"Joe Fletcher" joe_at_meng.ucl.ac.uk
"Eric M. Sisson" ems_at_mdacc.tmc.edu
pointed out that mtools has a built in dos2unix and unix2dos functions
and that Tru64 5.x comes with mtools installed.
__________________________________________________
Do You Yahoo!?
Make a great connection at Yahoo! Personals.
http://personals.yahoo.com
Received on Tue Oct 23 2001 - 02:15:31 NZDT