Solved

unix2dos and vi

Posted on 1998-10-27
7
983 Views
Last Modified: 2008-02-01
I need to be able to perform the equivalent of the unix2dos command from within vi. Among several failed attempts, here is one:
      :.,%s/\(.*\)/\1^M/g
where ^M is actually ^V^M

Incidentally, I got dos2unix working fine by doing:
      :.,%s/^M//g
Any ideas on unix2dos? The actual program is messed up on my system and I'd much rather be able to do it by hand with a simple global replacement.
0
Comment
Question by:Pakman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 51

Accepted Solution

by:
ahoffmann earned 50 total points
ID: 2007586
:.,$ !awk '{print $0,"\r"}'
0
 

Author Comment

by:Pakman
ID: 2007587
That results in each line ending with a space, then the carriage return. How can a 1-liner result in just the carriage return?
0
 
LVL 84

Expert Comment

by:ozo
ID: 2007588
awk '{print $0 "\r"}'
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 51

Expert Comment

by:ahoffmann
ID: 2007589
Oops, I forgot that , adds a space too. Thanks ozo.
0
 

Author Comment

by:Pakman
ID: 2007590
Not to be picky (maybe I'm using it wrong), but I am using this command (from the shell) to redirect to a temp file, then renaming the temp as original. Is there an easier way? How would you use that awk command from within the vi session?
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 2007591
:.,$ !awk '{print $0 "\r"}'

see the initial colon
0
 

Author Comment

by:Pakman
ID: 2007592
Got it to work. I must mention, however, that the following will do it for all lines (instead of from the current line till the end as the proposed answer indicates):
              :%!awk '{print $0 "\r"}'
0

Featured Post

What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap (http://www.tcpdump.org) Version 1.2 2.      Jpcap(http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/index.html) Version 0.6 Prerequisite: 1.      GCC …
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question