changing a ! to a \nC where \n is a newline
eric.sweetman
exs at cbnewsk.att.com
Sat Sep 22 04:30:49 AEST 1990
In article <5015 at alpha.cam.nist.gov>, Sean Coleman ) writes:
> I am trying to use the global substitution power in vi to
> replace every occurrence of ! with a newline and a C (\nC)
> ...
> How about the reverse, replace a newline with a character?
A shell solution to replacing a newline with another character is
to use the tr command which translates a single character into
another. For example, cat forbar|tr '\012' ' '>tmp replaces
newlines in foobar with spaces and places output in tmp. 012
is the octal code for newline. Other uses for tr include:
tr '[a-z]' '[A-Z]' translates lower to upper case
tr '()' '{}' translates open(close) parentheses to open(close)
braces
Eric Sweetman exs at pruxm.ATT.COM
More information about the Comp.unix.shell
mailing list