Visit Our UNIX and Linux User Community


vi


 
Thread Tools Search this Thread
Operating Systems OS X (Apple) vi
# 1  
Old 10-09-2007
vi

I have a file that at some point I removed all ^Ms and now I'm trying to put a newline return where the ^Ms used to be.

I probably removed the ^Ms a few years ago in Linux or SCO Xenix and now I'm using a MAC.

With the file opened with vi I have tried the following:

:%s/\.[A-Z]/\.^N[A-Z]/g

I'm entering the ^N as ctrl-V ctrl-N and the /g is because as the file stands now I have 2 really long lines.

The results I'm getting are just the literal ^N[A-Z].
# 2  
Old 10-10-2007
I could be wrong, but on unix machines (like the Mac ;P ) the line endings (newline character) are generally referenced in regular expressions as "\n".

yes?

Not being a vi guy, I do not know if regular expressions are handled the same way there...

https://www.unix.com/shell-programmin...feeds-csv.html
# 3  
Old 10-10-2007
use this

without having to go to vi editor, you cud just use use

sed 's/.*$/&\^N/g' filename > outfile


or inside vi, u cud do

:1,$s/.*$/&\^N/g

cheers,
Devaraj Takhellambam
# 4  
Old 10-26-2007
^M in document

the up carrot M is the Microsoft equiv to carriage return.
if they are appearing in the document or file its because they were either created or modified in MS Notepad or WordPad

I haven't seen them actually impacting or impair the operation, so I ignore them.
# 5  
Old 10-29-2007
Quote:
Originally Posted by cafe_latte
the up carrot M is the Microsoft equiv to carriage return.
if they are appearing in the document or file its because they were either created or modified in MS Notepad or WordPad

I haven't seen them actually impacting or impair the operation, so I ignore them.
In Linux, the simplest way to get rid of those funnies is using dos2unix command. No idea if something similar exists in OS X
# 6  
Old 04-10-2008
I've been using this to remove the annoying ^M from dos files:

col -bx <dosfile> newfile

and I'm pretty sure it works under OS X.

al
....
# 7  
Old 04-11-2008
A dos2unix-like tool for the Mac may be found here:

OS X Apps > search: "newline"

Cheers,
verno

Previous Thread | Next Thread
Test Your Knowledge in Computers #685
Difficulty: Medium
Reverse Polish notation (RPN), also known as Polish programming notation.
True or False?

Featured Tech Videos