find/replace special characters

How can I find/relace carrage returns in a text document.  Currently I use both sed and vi to find and replace text:
$sed s/findme/replacewith/g filename > filename.ver2
or in vi I use:

but return charaters seem to be tricky to recognize this way?!

Thanks in advance
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

cschuesslerConnect With a Mentor Commented:
In your sed statement, try a cntrl-v before you put in the carrage return.  this is similar to a \ in programming.  You may have to find out which other cntrl character it may be depending on what flavor of Unix you are running, but this should work.  Good Luck
You can do it much simpler, by means of command "tr".
"tr" may use octal ascii-numbers instead of normal characters.
newline has ascii-value 10, which is "12" in octal representation.
If you want to replace alle the newlines in a file with, for instance, "&", the command is:

cat <filename> | tr "\12" "\46" > <newfile>

(the "&" has octal ascii value "46")

To print the octal and hexadecimal tables, try:  man ascii

good luck  ;)
that will work as well...I don't know if it's really "much simpler", but whatever works...Good luck
All Courses

From novice to tech pro — start learning today.