Bit and Byte readers?

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 (...


Go Back   Usenet Forums > Linux Forums > Linux General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 03-22-2006
dhbspam@gmail.com
 
Posts: n/a
Default Bit and Byte readers?

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

Reply With Quote
  #2 (permalink)  
Old 03-22-2006
Jean-David Beyer
 
Posts: n/a
Default Re: Bit and Byte readers?

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
Reply With Quote
  #3 (permalink)  
Old 03-22-2006
dhbspam@gmail.com
 
Posts: n/a
Default Re: Bit and Byte readers?

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


Reply With Quote
  #4 (permalink)  
Old 03-22-2006
Eric Moors
 
Posts: n/a
Default Re: Bit and Byte readers?


> 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;
}

Reply With Quote
  #5 (permalink)  
Old 03-24-2006
Shmuel (Seymour J.) Metz
 
Posts: n/a
Default Re: Bit and Byte readers?

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

Reply With Quote
  #6 (permalink)  
Old 03-24-2006
Robert M. Riches Jr.
 
Posts: n/a
Default Re: Bit and Byte readers?

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.)
Reply With Quote
  #7 (permalink)  
Old 03-25-2006
The Natural Philosopher
 
Posts: n/a
Default Re: Bit and Byte readers?

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.
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 05:40 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0