Previous I was using flip command for MKS toolkit, but now I have cygwin with me. So Please let me know flip -dbc equivalent command in cygwin. I have flip command, in cygwin. I am looking for the same behavior in cygwin which was provided by -dbc options in MKS toolkit.
1 Answers
flip -mb - is almost equivalent (see cygwin flip manpage), you need to cat the file to flip, though.
From the MKS toolkit manpage for flip:
-b forces the conversion of files containing binary characters. Normally, flip returns an error if it encounters a binary character.
-c sends the converted results to standard output rather than overwriting the original file. This option is useful when working with files for which you do not have write permissions, or when piping and redirecting the output elsewhere.
-d converts file to use PC format line delimiters. This option changes all instances of a single Line Feed character into a Carriage Return/Line Feed combination. Stand alone Carriage Returns are not affected.
You could also write your own program to do it:
#!/usr/bin/awk -f
/!\r$/
{print $0 "\r"}
The above program appends a carriage return character to each line that does not have one before the newline character, emulating flip. It takes an input file.
You can save this to a file in your path, name it flipper and chmod +x it. To run your flipper:
First, we check our sample file has UNIX line endings:
$ file myTextFile.txt
/cygdrive/c/myTextFile.txt: ASCII text
Now we use the program to flip the file to a new file and check that the new file has DOS line endings:
$ flipper myTextFile.txt > myTextFile-fixed.txt
$ file myTextFile-fixed.txt
/cygdrive/c/myTextFile-fixed.txt: ASCII text, with CRLF line terminators
Testing without redirection:
$ flipper myTextFile.txt
Hello
World
!
- 470