Byte Out (bo) program


Govand Sinjari


Not sure if there is command line can output a specific number of bytes from a file in specific format?

I have written a tiny program in C for that, for example if you run ./bo 10 x file , it will output first 10 bytes of the file in Hex. The program can use any format specifier of printf like x, c, d, o, s, f, etc.

If there is no such command, I want to submitted to public domain, will it be possible to add it to linux commands? how?

I have compiled the command for Mac and Kali, it is attached


    1.9 KB · Views: 646

I appreciate items like this when I need to do something repeatedly.

I don't know of a "single" command to do this - there may be one.


head -n1 file.txt | cut -b-6 | od -x
head -n1 file.txt | cut -c-6 | od -x

would do the same thing. This approach also lets you choose what line (use head and tail), and you can still choose character count and format. You could throw this into a shell script and pass variables to do the same thing.

Cool little utility though. I have a bunch of "special purpose" programs and scripts for stuff I need to do all the time, so I understand the need to create things like this.
Thanks unixfish, very useful commands, I knew what each one does but never used it like that.

Members online