Robin Turner wrote:
> 
> On Thursday 14 February 2002 05:17, Franki wrote:
> > Hi all,
> >
> > I have many perl scripts in a directory that all contain windows
> > control characters..
> >
> > I would like to make a shell script or something that will go
> > through all the files in a directory, (and any sub directores)
> > grep every file for ^M characters and swap them for their unix
> > equivalent....
> >
> > has anyone ever done this?
> >
> > PS, the only txt editor that allowed me to see the ^M's was vi,
> > pico and others did not show them.. why is that?
> 
> On Thursday 14 February 2002 05:17, Franki wrote:
> > Hi all,
> >
> > I have many perl scripts in a directory that all contain windows
> > control characters..
> >
> > I would like to make a shell script or something that will go
> > through all the files in a directory, (and any sub directores)
> > grep every file for ^M characters and swap them for their unix
> > equivalent....
> >
> > has anyone ever done this?
> >
> > PS, the only txt editor that allowed me to see the ^M's was vi,
> > pico and others did not show them.. why is that?
> 
> AFAIK KWrite doesn't show, but does give the opportunity to, say,
> search/replace regexps, and change the EOL character.  I'm still
> finding I have the same problem - I converted a ton of Word documents
> ages ago (with noword, IIRC) but some control characters just won't
> go, no matter what kind of substitutions I run on them; e.g.,
> 
> s/t+//g;
> 
> should get rid of tabs, but doesn't.

open the file in vi or vim, and when in command mode, use the foll
command:
:%s/^M//g

now the ^M is not <shift><6>, <shift><m> rather it is obtained by:
<ctrl><v>,<ctrl><m>

if you have some problem with this command, play around a bit, then
mail me, i'll give you a key by key sequence. but i doubt you'll need
it.

let me break down the command
% => for the entire file as scope
s => search and replace eg. s/old_data/new_data/
g => global i.e for all occurances of old_data

between the 2nd and 3rd foward-slash there is nothing, not even a
space. thus we are effectivly deleting that character by replacing it
with nothing.

just showing off :-P

mario
-- 
 "The software said 'runs on Win95 or better,' so I installed it on
Linux"

Want to buy your Pack or Services from MandrakeSoft? 
Go to http://www.mandrakestore.com

Reply via email to