Convert
ASCII text that comes from DOS/Windows to Unix format
How do I convert ASCII text that comes from DOS/Windows to Unix format and vice-versa? In addition, I need the file time to be left unchanged! It's easy to do a 'tr' script or write a small piece of C code, but you should better use the GNU software 'recode', it does the job and keeps the file time intact. From Unix to DOS:
From DOS to Unix:
No, the two dots are not a typo, that's just 'recode'
syntax.
Convert data from Binary to ASCII Does anybody know how to convert data from 2-byte binary format into ASCII format for viewing? What OS is MS 2000??
"od -c filename" should display the file as ascii characters where possible. But a byte value can range from 0 to 255 and ASCII characters
are defined only from 0 to 127 and not all of those are printable characters.
I don't remember how "od -c" will display non-ascii values.
If you just want to see the values of the bytes (not necessarily as ASCII characters), you can use: od -x filename This will display the hex values of the bytes. There are
other options also.
Those commands may be useful, but what I'm really trying to do is compile c code in UNIX which can convert a binary datafile to ASCII. From there, I can use winRAR to extract the data for viewing. Any thoughts on this are welcome...thanks Binary to ascii is not really defined.
If you are talking about moving files using FTP, there is the issue of binary files versus ascii files because of the different representation of "the new line" in unix and in windows. UNIX uses just a "linefeed" and windows uses "linefeed" and "carriage return". So, if you made the mistake to download a test file (or html etc.) in binary format from a UNIX based server, it would not display right in windows. You could fix this with ftp in pumping it up binary and back down in ascii, or you could use tr or an editor to replace each "linefeed" by "linefeed carriage return" So, what exactly is your issue? If you just want to look for printable characters in some executables, octaldump "od -c filename" or "strings filename | more" will do it.
Have a Unix Problem
Unix Books :-
Return to : - Unix System Administration Hints and Tips (c) www.gotothings.com All material on this site is Copyright.
|