1837984 Members
2748 Online
110124 Solutions
New Discussion

Re: vi question

 
SOLVED
Go to solution
Igor Sovin
Super Advisor

vi question

Hi!
How to delete the last symbol of each strings in the whole file?
8 REPLIES 8
Raj D.
Honored Contributor

Re: vi question

Igor,

You can use sed as well ,
Check out this :


vi Reference
http://www.cis.ksu.edu/~bhoward/vi/vi60.html
--------------------------------------------

sed Reference:

http://www.student.northpark.edu/pemente/sed/sed1line.txt
--------------

Cheers,
Raj.
" If u think u can , If u think u cannot , - You are always Right . "
Igor Sovin
Super Advisor

Re: vi question

I need to delete ^M symbol at the end of the each line, but vi interpretes ^M as one symbol and when I type ^M in my substitution construction I can only type it as two symbols ^ and M, so pattern doesnt match. Thats the problem.
Asif Sharif
Honored Contributor
Solution

Re: vi question

Hi Posatskov,
Use this command.

#dos2ux filename filename

for further reference please have a look on the following link.

http://docs.hp.com/en/B2355-90689/dos2ux.1.html

Regards,
Asif Sharif
Regards,
Asif Sharif
Arunvijai_4
Honored Contributor

Re: vi question

Hi Igor,

To delete ^M, you can use the following,

# strings

# sed 's(ctrl v ctrl m)g//g' old.file > new.file

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
Victor Fridyev
Honored Contributor

Re: vi question

Hi,

In additioto to dos2unix in vi:

In order to insert ctrl-character use:
CTRL-V CTRL-CHTR.
I your case :
vi file,
:%s/CTRL-VCTRL-M$//
:wq

HTH
Entities are not to be multiplied beyond necessity - RTFM
inventsekar_1
Respected Contributor

Re: vi question

try this:
Remove control-M's from a windows text file.
cat $1 | tr -d "\015"
Be Tomorrow, Today.
Igor Sovin
Super Advisor

Re: vi question

thank you guys!
Bill Hassell
Honored Contributor

Re: vi question

And the reason you have a file with this strange character is that you transferred a file from a PC to HP-UX. Because PCs have very different file formats, you need to transfer these text files with ftp's special translation feature called ASCII. And this is required to send HP-UX text files to a PC -- always use the ASCII option.

But for all current files on your HP-UX system, don't bother with vi or sed, just use the two special commands that perform the translation: dos2ux and ux2dos


Bill Hassell, sysadmin