ANNOUNCEMENT: Live Wireshark University & Allegro Packets online APAC Wireshark Training Session
April 17th, 2024 | 14:30-16:00 SGT (UTC+8) | Online

Wireshark-dev: Re: [Wireshark-dev] [Wireshark-commits] rev 20491: /trunk/docbook/ /trunk/docboo

From: Sake Blok <sake@xxxxxxxxxx>
Date: Fri, 19 Jan 2007 10:17:15 +0100
On Thu, Jan 18, 2007 at 04:20:40PM -0800, Guy Harris wrote:
> 
> On Jan 18, 2007, at 4:08 PM, Sebastien Tandel wrote:
> 
> >>  Is it safe to assume that dos2unix is available on a common UNIX  
> >> developer machine?!?
> >
> > Nope, it is not ... :-/
> 
> No, but
> 
> 	tr -d '\015' <file_with_CR_LF_line_endings >file_with_LF_line_endings
> 
> will probably be available.  (Unfortunately, "tr" isn't able to do  
> unix2dos.)

Since 'sed' is a requirement for a development-environment, it can also
be used for EOL transformations:

dos2unix: sed -e 's/^M$//'  <-- Use ctrl-v ctrl-m to create the ^M
unix2dos: sed -e 's/$/^M/'  <-- Use ctrl-v ctrl-m to create the ^M

Unfortunately "\r" is not recognized by sed on all platforms and 
neither is \015. Therefore we have to use the raw CR character.

Cheers,


Sake

PS  To prevent to over-dosizise the EOL's, you can also check whether
    there is already a CR by using: sed -e 's/[^^M]$/^M/'