Flip – Convert text file line endings between Unix and DOS formats

This program converts line endings of text files between MS-DOS and **IX formats. It detects binary files in a nearly foolproof way and leaves them alone unless you override this. It will also leave files alone that are already in the right format and preserves file timestamps. User interrupts are handled gracefully and no garbage or corrupted files left behind. ‘flip’ does not convert files to a different character set, and it can not handle Apple Macintosh line endings (CR only). For that (and more), you can use the ‘recode’ program (package ‘recode’).

Install flip in debian

#apt-get install flip

This will complete the installation.

Flip Syntax

flip -h

flip -umvtsbz file

Available option

-u   convert to **IX format (CR LF => LF, lone CR or LF unchanged, trailing control Z removed, embedded control Z unchanged)

-m   convert to MS-DOS format (lone LF => CR LF, lone CR unchanged)

-h   give a help message

-v   be verbose, print filenames as they are processed

-t   touch files (don’t preserve timestamps)

-s   strip high bit

-b   convert binary files too (else binary files are left unchanged)

-z   truncate file at first control Z encountered

Flip Examples

file.txt is a dos file with ^Ms at the end of each line.

file file.txt

file.txt: ASCII text, with CRLF, LF line terminators

1)flip -u file.txt

file file.txt

file.txt: ASCII text

Again converting to dos format

2) flip -m file.txt

file file.txt

file.txt: ASCII text, with CRLF line terminators

This command is also called alternative to dos2unix,unix2dos commands

Sponsored Link

9 thoughts on “Flip – Convert text file line endings between Unix and DOS formats

  1. There’s even more powerful tool named konwert.
    I do agree with Steve, what’s wrong with the most standard and popular tools that can be found in most of UNIX and Linux systems?

  2. This works extremely well, with the added benefit of not needed an additional command installed, AND will not mangle a file that isn’t dos line endings:
    tr -s '1512\n\r' '\n'

  3. Is there a way to have flip work on the standard output from cat’ing multiple files together or do you have to save the output of cat to a temp file first and then flip it?

Leave a comment

Your email address will not be published. Required fields are marked *