Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Substitute a newline character

Status
Not open for further replies.

grega

Programmer
Feb 2, 2000
932
GB
Wracking my brains on this to no avail! How do I substitute a "newline" character into a file? Say I have a comma separated file containing
Code:
a,b,c,d
and I want to change it to
Code:
a
b
c
d
Specifically interested in sed or the vi substitution string (for which I use :g/find this/s//change to this/g

Thanks in advance.

Greg.
 
grega,
You already have a newline at the end of each record, so in vi you could type:
1,$s/,/ctrl-vctrl-m/g
the control v indicates the next character is a control character which in this case is control-m (newline).
Hope this helps
 
or (and this is a *typical* vi trick) you could type

%s/,/ctrl-vctrl-m/g

1,$ means "from line 1 to the end of the file" and so does %
Mike
michael.j.lacey@ntlworld.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top