Re: [SLUG] Conversion question

From: Chuck Hast (wchast@gmail.com)
Date: Thu Jan 18 2007 - 15:46:32 EST


On 1/18/07, Eben King <eben01@verizon.net> wrote:
> 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.
>
> -

What we have is data coming out of some files in proc, this data changes
constantly depending on the data links and what the timers are doing. What
we are doing is in one case when a certain command is called from the
switch interface, capturing a snapshot of that data and dumping it to the
requesiting user. In some cases we need to see it in dos format and in others
with just a CR on the end. I thought we only needed to see the dos format
for those people who are using windows, but turns out there are times when
we need to see the line ended with a CR, and it appears that good old Linux
pretty well handles whatever is tossed at it, too bad some others do not...

I will test more of this until I get the answer I am looking for, thanks for the
work with the dos format, that is working great, now just to clear up the last
one with the NL ending in a CR only... Then I will have the whole mess
covered.

Thanks for you guys patience and help that is for sure. Because of help like
this the amateur packet radio network in Florida is being converted over to
Linux at the network level, now we just have to get the users on board.

-- 
Chuck Hast  -- KP4DJT --
To paraphrase my flight instructor;
"the only dumb question is the one you DID NOT ask resulting in my going
out and having to identify your bits and pieces in the midst of torn
and twisted metal."
-----------------------------------------------------------------------
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:16 EDT