You are testing with an ASCII file so are missing to observe these negative values. Use a truly binary input file.
It is also compiler dependent. With some compilers type char is signed; in other compilers it is unsigned. In compilers with type char == type signed char, you'll get negative numbers from the bytes with the high bit set when printing in decimal format as in:
but on systems where od was built using a compiler with type char == type unsigned char, you'll get the output:
with the same input.
Note also that with od -An you get leading spaces where the address would go if you were printing it. That is causing some unwanted zeros to appear in the output corresponding to the start of each line of od output. To get around both of these problem you could try:
I see RudiC already posted the -tu1 fix. I hope the explanation of why -td1 didn't work helps and that the added grep gives you what you want.
I don't have a Solaris system I can use for testing, but on OS X I'm not getting leading zeros printed by od -tu1, but if that is a problem on Solaris systems, you could change the:
in the pipeline to:
@guddu_12 Beware that the initial C source code I posted had a bug, it is fixed now. It takes 30 ms for a 10k file.
@wisecracker {0..15} is not POSIX. In any case, as already stated, your algorithm is too slow to be usable with anything but tiny files. It takes 26 minutes for the same 10k file
@Don Cragun, with the extra awk code, your script works fine under Solaris and takes 17 seconds for the same 10k file.
Here is a mostly awk based solution that takes 230 ms:
Hello to all guys,
Maybe some expert could help me.
I have a working ruby script shown below that reads a big binary file (more than 2GB). The chunks of data I want to analyze
is separated by the sequence FF47 withing the binary. So, in the ruby script is defined as "line separator" =... (10 Replies)
Hi ,
i have a parameter which has path of a file. Now i need to have another parameter with the content of that file. I tried the belwo script , can any one please help.
I dont want to use cat command to read. Can we do it with out using cat command.
while read line
do... (9 Replies)
this is my code and no matter what record number the user enters i cant get any of the records fields to read into the structure acct. What am i doing wrong?
#include <stdio.h>
typedef struct
{
char name;
int number;
float balance;
} acct_info_t;
int main (int... (0 Replies)
Hello.
I've written up a script, that populates a variable with a list of tapes returned from my library. For example:
701940L3,701941L3,701942L3,701943L3,701944L3,701945L3,701946L3,701947L3,701948L3
So now, the variable "TAPELIST" contains those numbers, delimited by commas. I'd like to... (6 Replies)
Hi,
I am reading a file line by line using read line function of while loop. Each line contains 4 fields. I want to take these 4 values in 4 variables in each iteration so that i can use them in my script. The issue here is that my awk command is returning awkward results -
Here is a sample line... (8 Replies)
Hi,
I've searched and couldn't find anyone else with this problem. Is there anyway (preferably using ksh - but other script languages would do) that I can read in binary float data into a text file. The data (arrays from various stages of radar processing) comes in various formats, but mainly... (3 Replies)
I'm having trouble with reading information back into a program from a binary file. when i try to display the contents of the file i get a Memory fault(coredump). would anyone be able to assist?
this is my fread line fread(&file_data,sizeof(struct book_type),1,fileSave); ive also tried it without... (3 Replies)