?
Solved

unix2dos and vi

Posted on 1998-10-27
7
Medium Priority
?
991 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 150 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
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

 
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Installing FreeBSD… FreeBSD is a darling of an operating system. The stability and usability make it a clear choice for servers and desktops (for the cunning). Savvy?  The Ports collection makes available every popular FOSS application and packag…
I have been running these systems for a few years now and I am just very happy with them.   I just wanted to share the manual that I have created for upgrades and other things.  Oooh yes! FreeBSD makes me happy (as a server), no maintenance and I al…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Suggested Courses
Course of the Month13 days, 2 hours left to enroll

777 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