![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Binary txt file received when i use uuencode to send txt file as attachment | ash22 | UNIX for Dummies Questions & Answers | 2 | 04-24-2008 08:03 PM |
| compiled binary file gives "cannot execute binary file" | scgupta | SUN Solaris | 0 | 07-13-2006 01:59 AM |
| binary file | markms | UNIX for Dummies Questions & Answers | 1 | 04-07-2006 09:40 AM |
| binary file | ramneek | UNIX for Dummies Questions & Answers | 1 | 09-13-2005 05:02 PM |
| Binary File Transfer | DPAI | High Level Programming | 2 | 03-04-2002 03:12 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
If you mean binary in the unix sense (no carriage control)
use the command "file", and it is not some type of ELF or a.out format file: file filename for a "binary" file returns filename: data If file finds carriage control (newlines) and printable ascii characters: filename: ascii data Otherwise, it uses a magic number to figure out what type of file you are dealing with. On PC's under DOS or Windows, binary files do not have exactly the same meaning they do for unix, nor does the file system handle them the same way. The EOF marker for text files is control-Z, ASCII 26. Binary files keep the length of the file in the FAT, and treat ascii 26 as an ordinary character. Unix does not do this. There is no EOF marker in the file. Binary and ascii files are handled the same way by the file system. It keeps track of where the file ends. |
|
||||
|
The file command will tell you the type of file - most of the time!
Because it is using the contents of the file it can sometimes get the answer wrong. A different way of looking for a file type is to use the find command with the -type conjunction. Also certain file types have a disctinct 'marker' in the data. e.g. some TIF files will have 0x490x49 as the first two bytes. Although you could write a program to look for this TIF marker, it would be very easy to fool it with a hoax file. And now, I hope you will appreciate the limitations with the file command. |
|
||||
|
mbb -
In unix a file is a bag of bytes. Period. There is no such thing as a binary file or a text file, except perhaps in terms of how you retreive data from it, or which magic number the file has. All I/O uses base modules like read. The higher-level i/o modules call read, then play with the data in the buffer and return chunks of it. Windows programmers insist on "binary". When they come to linux it takes them along time to figure out what the file system actually does. |
![]() |
| Bookmarks |
| Tags |
| linux |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|