Re: [SLUG] Conversion question

From: Paul M Foster (paulf@quillandmouse.com)
Date: Wed Jan 17 2007 - 14:36:31 EST


Chuck Hast wrote:
> I am dealing with that old buggaboo, the end of line conventions which for
> unix type systems is the 0x0A or LF. For dos/win it is 0x0D or the CR.
>
> If I was just converting the file for dos/win use I would just run it
> through
> unix2dos and let it dump it into a new file with the proper format. But in
> this case I have a small script that reads a file out to the screen, so
> what
> I need to do is the conversion and have the result dumped to the screen,
> here is a sample of one, it reads the file from one of the files in proc.
>
> #!/bin/bash
> #
> while : ; do
> cat /proc/net/rose_neigh
> sleep 1
> clear
> done
>
> This is the output:
> addr callsign dev count use mode restart t0 tf digipeaters
> 00043 KC5QCN-9 sp0 10 0 DTE no 0 0
> 00042 KD4YAL-9 ax0 1 1 DTE yes 0 0
> 00041 W4MIN-9 ax0 1 0 DTE no 0 0
> 00040 N3PPC-9 ax0 2 0 DCE yes 0 0
> 00039 N4PLZ-9 ax0 8 1 DCE yes 0 0
> 00038 F5KBW-9 ax0 9 1 DTE yes 0 0
> 00037 F6BVP-11 ax0 12 0 DTE yes 0 0
> 00036 VK2TV-2 ax0 1 1 DCE yes 0 0
> 00032 K4GBB-9 ax0 12 1 DTE yes 0 0
> 00001 RSLOOP-0 ??? 5 0 DCE yes 0 0
>
> This is the output if viewed on a win machine:
>
> addr callsign dev count use mode restart t0 tf digipeaters
> 00043 KC5QCN-9 sp0 10 0 DTE no 0 0
>
> 00042 KD4YAL-9 ax0 1 1 DTE yes 0 0
> 00041 W4MIN-9 ax0 1 0 DTE no 0 0
>
> 00040 N3PPC-9 ax0 2 0 DCE yes 0 0
> 00039 N4PLZ-9 ax0 8 1 DCE yes
> 0 0
> So I need to add unix2dos or a sed statement that will intercept the
> file and
> do the conversion and then output it to the screen.
>
> I am way down at the bottom when it comes to scripts as you can see. I
> bet there is a better way to even do that script, but little by little.
>

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

You could put that in a script, if you like. The output will be to
screen, with line endings of CR/LF.

Paul

-- 
Paul M. Foster
-----------------------------------------------------------------------
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:37:25 EDT