Solved

unix2dos and vi

Posted on 1998-10-27
7
981 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
Independent Software Vendors: 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

When you do backups in the Solaris Operating System, the file system must be inactive. Otherwise, the output may be inconsistent. A file system is inactive when it's unmounted or it's write-locked by the operating system. Although the fssnap utility…
Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
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…
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…

739 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