Re: [SLUG] Conversion question

From: Eben King (eben01@verizon.net)
Date: Thu Jan 18 2007 - 15:19:10 EST


On Thu, 18 Jan 2007, Chuck Hast wrote:

> Not trying to beat a dead horse, but I also need to send out a single CR
> at the end of line. I have tried to replace the \r with a \n in the sed
> line but it does not work.

So you have

l i n e 1 \n
l i n e 2 \n

(Linux style) and you want

l i n e 1 \r
l i n e 2 \r

(Mac style)?

Then

tr '\n' '\r' < infile > outfile

should work. Warning, this will scramble binary data, so make sure infile
is text. It'll overwrite outfile if it exists too.

Or if (given the same source file) you want

l i n e 1 \n \r
l i n e 2 \n \r

(MSDOS style)

there's a command in vim to do it, but I've never needed it, so I never
learned it.

unix2dos < infile > outfile

is the most straightforward way. You can also open & save a single file in
WORDPAD.EXE .

> Not sure what I am doing wrong as I see it the s command replaces the
> following char with the next one in line? sed 's/\n/\r' file ? I think I
> read it as Substitute n for r ?

Maybe, depending on what you mean. When sed gets a \n (NL) it writes a \r
(LF) in place of it.

-- 
-eben   QebWenE01R@vTerYizUonI.nOetP   royalty.no-ip.org:81

Drive nail here > < for new monitor. ----------------------------------------------------------------------- This list is provided as an unmoderated internet service by Networked Knowledge Systems (NKS). Views and opinions expressed in messages posted are those of the author and do not necessarily reflect the official policy or position of NKS or any of its employees.



This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 20:41:05 EDT