Re: [SLUG] Conversion question

From: Chuck Hast (wchast@gmail.com)
Date: Wed Jan 17 2007 - 18:24:32 EST


On 1/17/07, Paul M Foster <paulf@quillandmouse.com> wrote:
> Chuck Hast wrote:
> > On 1/17/07, Eben King <eben01@verizon.net> wrote:
> >> On Wed, 17 Jan 2007, Chuck Hast wrote:
> >>
> >> > On 1/17/07, Eben King <eben01@verizon.net> wrote:
> >> >> On Wed, 17 Jan 2007, Paul M Foster wrote:
> >> >>
> >> >> > Chuck Hast wrote:
> >> >> >
> >> >> > For clarification:
> >> >> >
> >> >> > Line endings in Unix/Linux: LF (0x0a)
> >> >> > Line endings in DOS/Windows: CR/LF (0x0d 0x0a)
> >> >> > Line endings in Mac: CR (0x0d)
> >> >> >
> >> >> > Not quite sure why you're using a script. Just do:
> >> >> >
> >> >> > cat filename | dos2unix
> >> >>
> >> >> UUOC.
> >> >>
> >> >> dos2unix < filename
> >> >
> >> > I am guessing in this case it would be
> >> > unix2dos <filename?
> >>
> >> The file has Unix-style line endings (LF), and you want MSDOS-style
> >> endings
> >> (CR+LF), so yes.
> >>
> >> If you don't have those, you can change the endings appropriately with
> >> sed
> >> and tr.
> >>
> >> -
> >
> > Yep, but I have two utilities and unix2dos is the one to go from LF to
> > CR.+LF,
> > so figured I needed to use that one.
> >
> >
>
> Maybe some more fundamental advice might help (yes, I realize you solved
> the problem, Chuck).
>
> My original advice was:
>
> cat filename | unix2dos
>
> You probably realize that 'cat' just "concatenates" the file in question
> to 'stdout', which is normally the screen. When you put a '|' pipe there
> it connects the output of your 'cat' command with the input of the next
> command, in this case, unix2dos.
>

Yes, I understood what was going on there. That was my first idea was
something like that.

> Some commands are set up to gobble input from another program, like
> 'unix2dos'. Others aren't, like 'firefox'. So if you want to get them to
> gobble the input from something else (like the contents of a file), you
> have to do something that sends the output to the command. I recommended
> 'cat'.
>
> Eben made the comment that this was 'UUOC', or "useless use of cat", and
> he's right. You can accomplish the same thing by
>
> unix2dos < filename
>
Yes, I understood what was going on, nice and clean, shorter command,
the question was that dos2unix was used vice unix2dos and I just wanted
to make sure that I was doing the right thing. I assume it was a typo since
we are all back to unix2dos which is the direction I need to go.

> It's a simpler way of accomplishing the same thing. It has less overhead
> as it doesn't have to call the 'cat' command. It simply dumps the
> contents of the file and the '<' (less-than symbol) tells Linux where to
> send that output, in this case, to the 'unix2dos' command.
>
> You can also have something like this:
>
> unix2dos < filename > different_filename
>
> which runs the filename through unix2dos, and then dumps the output in a
> file named 'different_filename'.
>
> Or
>
> unix2dos < filename | dos2unix
>
> which would "pipe" the results of 'unix2dos < filename' to the command
> 'dos2unix', which should output exactly the file you started with.
>
> The rules for using <, > and | are sometimes a little hard to follow,
> but you get the idea.
>
This is all stuff I am trying to learn, so much neat things and so
little time...
I have the translation going now, and it looks good, I think I may have a
bad setting in the win side of the link as it is adding a additional LF in
there, but what is going out the radio now are lines terminated with CR+LF
and that is what I am looking for.

Thanks again folks for all of the help. This is why I like to work with Linux
plenty of help and different ways to get to the objective, all work and all
have their place.

-- 
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:39:46 EDT