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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

vi help

Status
Not open for further replies.

blx

MIS
Oct 9, 2002
23
GB
I want to be able to view control characters in vi. When I run a script created in vi, I get the following message "Bad Interpreter". I believe that it is because it has ^M character in the script at the end of each line, (however I would like to see which control characters appear in the script and then delete all instances of them).
Your help is really appreciated.

Blx
 
To get rid of ^M you can use sed :
sed 's/'`echo "\015"`'//g' yourfile > filenew

HTH
Dickie Bird (:)-)))
 
within vi you can do this as well:

type:

:%s/<ctrl>v<ctrl>M//g

It will strip away all ^M's out of file. Then save and exit. This way you don't have to send your output to another file like the post above or using dos2unix commands.
 
You can also use the command [tt]dos2unix[/tt] to remove the ^Ms.

 
bpinos:

that didn't work for me. It said: &quot;substitute pattern match failed.&quot;

Just so you know.

Thanks!

Nunina
 
None of the things you have said, has helped me with this problem. Any other suggestions?

Thanks!!!

Nunina
 
Nunina,

When I said <ctrl>, that means hold down the control key. Did you do that??
 
These files that you see a ^M at the end are files that might have been created in a M$ environment. To get rid of them, type:
dos2unix filename

What lunux distro are you using? You should have dos2unix installed.
 
So you are not sure whether you have ^M characters at all ?
Can you run this on your file to see what characters you have on each of the first 10 lines, and post the output here. Run:
head yourfile|od -hc

Dickie Bird (:)-)))
 
Thanks bpinos!!! Now it worked!!! I'm a little rusty in Unix (it's been about 4 yrs. since I last used it), and I kind of forgot some things.

But this helped a lot! Thank You!!!

Nunina
 
In vi use the set list command to view all control chars in a file (set nolist to turn off)

Greg.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top