Re: how to know a binary or text file and show all the information in file

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 19-12-07 09:18, C_C_Kuo@xxxxxxxxxxxxxx wrote:

Could someone tell me how to know the file is binary or ASCII? I know both of them are stream of bytes but interpreted by different ways.

I'm afraid your question means you are still confused with respect to this. Both type of files are _nothing_ but sequences of bytes, with only whatever interprets the contents making any sort of distinction between "binary", "ASCII", or more likely between "a C source file", "an Abiword document", "an OpenOffice.org spreadsheet" and so on.

My questions are:
1. How can I know this without opening it?

This specifically is not a correct question. There is nothing about the file itself (and certainly not in UNIX) that is "binary" or "ASCII" and as such, this is not a distinction that exists -- not one that can be made outside of the context of whatever is interpreting the content.

As I saw someone else saying as well, the "file" utility has a large database of signature content it can scan the file for to make educated guesses about what type of file it is -- but note that the phrase "what type of file it is" only means "which program created and/or is intended to act on the file" and nothing more.

2. how can I see all the information in a file, include all the control characters, like linein, print character and line feed, etc.

Usually, you'd use a hex viewer to view the raw sequence of bytes. Many of those around, and "xxd" might be one you have installed. To see a totally uninterpreted view of a file you'd use something like "xxd -g 0 file | less"

3. Is there any tool on Linux can open binary file?

Anything that can open files. As said, the distinction between "binary" files and other types does not exist at any level other than the interpreting one.

Muddying this discussion a bit are old dos/windows sources that opened files in "binary mode" -- it did have a concept of binary versus ascii, but that only consisted of translating \n into \r\n on writes and (possibly, not sute anymore and not going to test...) writing an ASCII 0x1a EOF marker on close.

4. Is there any tool on Linux can transfer ASCII to binary and binary to ASCII?

Yes. Any tool will do -- by not using it. I'll admit though that depends a bit on your willingness to view a transformation between two things that do not exist as an identity-transformation.

There are many tools do to all sorts of transformations on text files, but you'd first need to know/explain what it is that you'd want the tool to do before anyone can advice one.

Rene.

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux