Call now: 252-767-6166  
Oracle Training Oracle Support Development Oracle Apps

 E-mail Us
 Oracle Articles
New Oracle Articles

 Oracle Training
 Oracle Tips

 Oracle Forum
 Class Catalog

 Remote DBA
 Oracle Tuning
 Emergency 911
 RAC Support
 Apps Support
 Oracle Support

 SQL Tuning

 Oracle UNIX
 Oracle Linux
 Remote s
 Remote plans
 Application Server

 Oracle Forms
 Oracle Portal
 App Upgrades
 SQL Server
 Oracle Concepts
 Software Support

 Remote S


 Consulting Staff
 Consulting Prices
 Help Wanted!


 Oracle Posters
 Oracle Books

 Oracle Scripts

Don Burleson Blog 









Changing hidden characters with UNIX vi

Don Burleson


There are times when you need to do a "change all" command in UNIX vi or sed, but the character is a "control character" that you cannot specify inside the change command:





The change command in vi


The above is what a MS-Word documents looks like when pasted into the vi buffer.  In vi, a "change all" command looks like this:




This means:


<escape :>     Takes you to the vi command prompt

(dot)               Start on the current line

(comma)        Next parm

(dollar sign)   to end-of-file (EOF)

(s)                  Invoke the string editor (sed)

/old                The original string

/new               the new string

g                    global - Change all occurrences on a line


Removing the weird character


Now, what about removing the control character, ^M in our case?


We must "escape" the special character, using the <control> c key, like this, right before we enter the control m key::


:.,$s/<control c><control m>//g


When displayed in vi, it looks right:




Change all in a set of files


The script below will allow you to invoke it using a file mask and issue a sed command on many file, all at the same time.  For example:


root> ./ *.sql


In this case we changed all files with a .sql suffix.  If we look at the script, we changed all strings ":Avg" to "Sum".  With Perl, some claim that this can be some in a single command:


find . -name "*.sql" -print | xargs perl -pi -e 's/Avg/Sum/g'






mkdir $


for f in $*


  sed -e 's/Avg/Sum/g' < $f > $$f



# Whoops

mkdir $tmpdir.old

mv $* $tmpdir.old/

# Whoops


cd $

mv $* ../


cd ..

rmdir $




Oracle Training at Sea
oracle dba poster

Follow us on Twitter 
Oracle performance tuning software 
Oracle Linux poster


Burleson is the American Team

Note: This Oracle documentation was created as a support and Oracle training reference for use by our DBA performance tuning consulting professionals.  Feel free to ask questions on our Oracle forum.

Verify experience! Anyone considering using the services of an Oracle support expert should independently investigate their credentials and experience, and not rely on advertisements and self-proclaimed expertise. All legitimate Oracle experts publish their Oracle qualifications.

Errata?  Oracle technology is changing and we strive to update our BC Oracle support information.  If you find an error or have a suggestion for improving our content, we would appreciate your feedback.  Just  e-mail:  

and include the URL for the page.


Burleson Consulting

The Oracle of Database Support

Oracle Performance Tuning

Remote DBA Services


Copyright © 1996 -  2020

All rights reserved by Burleson

Oracle ® is the registered trademark of Oracle Corporation.