This is a discussion on Bit and Byte readers? within the Linux General forums, part of the Linux Forums category; Dear all, I am new to Linux, and need to read a file bit by bit, and in addition byte (...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Dear all,
I am new to Linux, and need to read a file bit by bit, and in addition byte (8 bits) by byte. Are there any tools available to accomplish either or both of these tasks? I've tried od, but that seems to read data in 3-bit chunks, which is not the granularity I need. Thanks, Dave |
|
|||
|
dhbspam@gmail.com wrote:
> Dear all, > I am new to Linux, and need to read a file bit by bit, and in > addition byte (8 bits) by byte. Are there any tools available to > accomplish either or both of these tasks? I've tried od, but that > seems to read data in 3-bit chunks, which is not the granularity I > need. > > Thanks, > Dave > man od -- .~. Jean-David Beyer Registered Linux User 85642. /V\ PGP-Key: 9A2FC99A Registered Machine 241939. /( )\ Shrewsbury, New Jersey http://counter.li.org ^^-^^ 06:25:01 up 6 days, 7:37, 3 users, load average: 4.39, 4.37, 4.27 |
|
|||
|
I've read the man od information, but I am not seeing how to change the
granularity. What am I missing? Jean-David Beyer wrote: > dhbspam@gmail.com wrote: > > Dear all, > > I am new to Linux, and need to read a file bit by bit, and in > > addition byte (8 bits) by byte. Are there any tools available to > > accomplish either or both of these tasks? I've tried od, but that > > seems to read data in 3-bit chunks, which is not the granularity I > > need. > > > > Thanks, > > Dave > > > man od > > -- > .~. Jean-David Beyer Registered Linux User 85642. > /V\ PGP-Key: 9A2FC99A Registered Machine 241939. > /( )\ Shrewsbury, New Jersey http://counter.li.org > ^^-^^ 06:25:01 up 6 days, 7:37, 3 users, load average: 4.39, 4.37, 4.27 |
|
|||
|
> I've read the man od information, but I am not seeing how to change the > granularity. What am I missing? > I guess a small C program is the easiest Adjust to your liking. Eric #include <stdio.h> int main(int argc, char *argv[]) { FILE *fp; char byte; int i, j =0; if (argc == 2) fp = fopen(argv[1], "r"); while (fp && !feof(fp) && !ferror(fp)) { if ((byte = fgetc(fp)) != EOF) { fprintf(stdout, "byte %d : ", j++); for (i = 7; i >= 0; i--) { fprintf(stdout, "%d", (byte >> i) & 0x01); } fprintf(stdout, "\n"); } } if (fp) fclose(fp); return 0; } |
|
|||
|
In <1143001089.236603.80200@i40g2000cwc.googlegroups. com>, on
03/21/2006 at 08:18 PM, dhbspam@gmail.com said: > I am new to Linux, and need to read a file bit by bit, On what computer? While in the past there have been computers that allowed you to address arbitrary bytes, almost every[1] contemporary computer is limited to 8-bit bytes (octets) on an eight-bit boundary. [1] I believe that Unisys still makes machines that can handle 6-bit bytes. -- Shmuel (Seymour J.) Metz, SysProg and JOAT <http://patriot.net/~shmuel> Unsolicited bulk E-mail subject to legal action. I reserve the right to publicly post or ridicule any abusive E-mail. Reply to domain Patriot dot net user shmuel+news to contact me. Do not reply to spamtrap@library.lspace.org |
|
|||
|
On 2006-03-24, Shmuel (Seymour J.) Metz <spamtrap@library.lspace.org.invalid> wrote:
> In <1143001089.236603.80200@i40g2000cwc.googlegroups. com>, on > 03/21/2006 > at 08:18 PM, dhbspam@gmail.com said: > >> I am new to Linux, and need to read a file bit by bit, > > On what computer? While in the past there have been computers that > allowed you to address arbitrary bytes, almost every[1] contemporary > computer is limited to 8-bit bytes (octets) on an eight-bit boundary. > > [1] I believe that Unisys still makes machines that can handle > 6-bit bytes. Maybe it's not considered "contemporary" any more, but Intel's 960 architecture, extended architecture level, has/had a bitstream object type. -- Robert Riches spamtrap42@verizon.net (Yes, that is one of my email addresses.) |
|
|||
|
Shmuel (Seymour J.) Metz wrote:
> In <1143001089.236603.80200@i40g2000cwc.googlegroups. com>, on > 03/21/2006 > at 08:18 PM, dhbspam@gmail.com said: > >> I am new to Linux, and need to read a file bit by bit, > > On what computer? While in the past there have been computers that > allowed you to address arbitrary bytes, almost every[1] contemporary > computer is limited to 8-bit bytes (octets) on an eight-bit boundary. > > [1] I believe that Unisys still makes machines that can handle > 6-bit bytes. > Its easy enough to do it by reading, AND'ing and OR'ing at the byte level, and rewriting. |