Using vi editor

Using vi editor

Post by AOW » Fri, 17 May 2002 12:20:05



Hello,
I have an ascii file that was ftped in binary mode. I am trying to
remove the special characters (^M) at the end of each line.
Is there an efficient way to remove them using vi? The file has
thousands of lines.

Thanks

 
 
 

Using vi editor

Post by William Hun » Fri, 17 May 2002 12:42:55



> Hello,
> I have an ascii file that was ftped in binary mode. I am trying to
> remove the special characters (^M) at the end of each line.
> Is there an efficient way to remove them using vi? The file has
> thousands of lines.

There must be a gaillion ways to do this!

free clue is to use '\r' for '^M'

more specifically:

:.,$s/\r//

okay?
--
William Hunt, Portland Oregon USA

 
 
 

Using vi editor

Post by Robert Bono » Fri, 17 May 2002 16:06:50



>Hello,
>I have an ascii file that was ftped in binary mode. I am trying to
>remove the special characters (^M) at the end of each line.
>Is there an efficient way to remove them using vi? The file has
>thousands of lines.

>Thanks

wrong question.

right answer:  "man tr"  ---  see the '-d' option.

 
 
 

Using vi editor

Post by JP » Fri, 17 May 2002 18:14:36



Quote:> Hello,
> I have an ascii file that was ftped in binary mode. I am trying to
> remove the special characters (^M) at the end of each line.
> Is there an efficient way to remove them using vi? The file has
> thousands of lines.

Try dos2unix as well...
 
 
 

Using vi editor

Post by Daniel Barsalo » Fri, 17 May 2002 22:57:17


In vi type  ":" to get in command mode and then type
1,%s/<ctrl-v><ctrl-m>//g

You should see something like this on the screen:
:1,%s/^M//g

<ctrl-v><ctrl-m>(typed one after the other) will type your ^M.

Daniel


> Hello,
> I have an ascii file that was ftped in binary mode. I am trying to
> remove the special characters (^M) at the end of each line.
> Is there an efficient way to remove them using vi? The file has
> thousands of lines.

> Thanks

 
 
 

Using vi editor

Post by Mishk » Sat, 18 May 2002 09:05:42



>Hello,
>I have an ascii file that was ftped in binary mode. I am trying to
>remove the special characters (^M) at the end of each line.
>Is there an efficient way to remove them using vi? The file has
>thousands of lines.

cat downloaded.file | tr -d "\r" > good.file

--
BR, Mishka.

 
 
 

Using vi editor

Post by AOW » Sat, 18 May 2002 08:44:54


Thanks  for everyone's input. The following command worked fine.
tr -d '\r' <input_file >output_file


> >Hello,
> >I have an ascii file that was ftped in binary mode. I am trying to
> >remove the special characters (^M) at the end of each line.
> >Is there an efficient way to remove them using vi? The file has
> >thousands of lines.

> cat downloaded.file | tr -d "\r" > good.file

> --
> BR, Mishka.

 
 
 

Using vi editor

Post by Nicholas Bachman » Sat, 18 May 2002 10:21:07




>>Hello,
>>I have an ascii file that was ftped in binary mode. I am trying to
>>remove the special characters (^M) at the end of each line.
>>Is there an efficient way to remove them using vi? The file has
>>thousands of lines.

> cat downloaded.file | tr -d "\r" > good.file

Congradulations on a Useless Use of Cat.

tr -d "\r" downloaded.file > good.file

--
* Nicholas Bachmann, SSCP                       *
* http://hermie.freeshell.org                   *
* http://www.not-real.org                       *
* My email address is real.                     *

 
 
 

Using vi editor

Post by Chris F.A. Johnso » Sat, 18 May 2002 12:10:45





>>>Hello,
>>>I have an ascii file that was ftped in binary mode. I am trying to
>>>remove the special characters (^M) at the end of each line.
>>>Is there an efficient way to remove them using vi? The file has
>>>thousands of lines.

>> cat downloaded.file | tr -d "\r" > good.file

> Congradulations on a Useless Use of Cat.

> tr -d "\r" downloaded.file > good.file

     We've all made this mistake at one time or another. The input
     file needs redirection; tr doesn't read file names on the command
     line:

        tr -d "\r" < downloaded.file > good.file

--

        =================================================================


 
 
 

Using vi editor

Post by Mishk » Sun, 19 May 2002 08:49:33





>>>Hello,
>>>I have an ascii file that was ftped in binary mode. I am trying to
>>>remove the special characters (^M) at the end of each line.
>>>Is there an efficient way to remove them using vi? The file has
>>>thousands of lines.

>> cat downloaded.file | tr -d "\r" > good.file
>Congradulations on a Useless Use of Cat.
>tr -d "\r" downloaded.file > good.file

AFAIK, tr(1) can't accept filename as argument (at least in BSD version).

--
BR, Mishka.

 
 
 

Using vi editor

Post by Nicholas Bachman » Sun, 19 May 2002 07:57:02






>>>>Hello,
>>>>I have an ascii file that was ftped in binary mode. I am trying to
>>>>remove the special characters (^M) at the end of each line.
>>>>Is there an efficient way to remove them using vi? The file has
>>>>thousands of lines.

>>>cat downloaded.file | tr -d "\r" > good.file

>>Congradulations on a Useless Use of Cat.

>>tr -d "\r" downloaded.file > good.file

> AFAIK, tr(1) can't accept filename as argument (at least in BSD version).

> --
> BR, Mishka.

Yes, that should have been tr -d "\r" < downloaded.file > good.file as
Chris pointed out.  The point was, in Randal Schwartz style, that using
cat was a Useless Use of Cat.

--
* Nicholas Bachmann, SSCP                       *
* http://hermie.freeshell.org                   *
* http://www.not-real.org                       *
* My email address is real.                     *

 
 
 

Using vi editor

Post by Peter Booste » Sat, 25 May 2002 15:01:16



Bonomi claimed...


> >Hello,
> >I have an ascii file that was ftped in binary mode. I am trying to
> >remove the special characters (^M) at the end of each line.
> >Is there an efficient way to remove them using vi? The file has
> >thousands of lines.

> >Thanks

> wrong question.

Why's that?

Quote:

> right answer:  "man tr"  ---  see the '-d' option.

How about (in vi):

:1,$s/^V^M//g

(the "^V^M" means: first press <CTRL><V> then <CTRL><M>)

Peter

--
It never hurts to help - Eek! the Cat.

 
 
 

Using vi editor

Post by steve ove » Sun, 26 May 2002 01:15:58





> > Hello,
> > I have an ascii file that was ftped in binary mode. I am trying to
> > remove the special characters (^M) at the end of each line.
> > Is there an efficient way to remove them using vi? The file has
> > thousands of lines.

> Try dos2unix as well...

unixware7 has the amusing named "detox" for this

steve