views:

553

answers:

4

I would guess most people on this site are familiar with tail, if not - it provides a "follow" mode that as text is appended to the file tail will dump those characters out to the terminal.

What I am looking for (and possibly to write myself if necessary) is a version of tail that works on binary files. Basically I have a wireless link that I would like to trickle a file across as it comes down from another network link. Looking over the tail source code it wouldn't be too hard to rewrite, but I would rather not reinvent the wheel! This wouldn't strictly be "tail" as I would like the entire file to be copied, but it would watch as new bytes were added and stream those.

Ideas?

+2  A: 

Pipe it to hexdump:

tail -f somefile | hexdump -C
Adam Pierce
wow I didn't think that would work
MattSmith
I wasn't 100% sure myself but I tried it and it works just fine.
Adam Pierce
Wouldn't tail -f only output new data when it saw a newline in the binary file? I doubt it unbuffers its stdout.
Chris Young
Good point Chris, I didn't think of that. So I just tested it now on Debian and yes, it still works if there are no newlines in the stream although that behaviour might be different on different platforms.
Adam Pierce
The use of hexdump is a red herring, isn't it? Or perhaps just an illustration of somewhere to send the binary data. I don't see anything in the question asking for a hexdump, that's all...
Jonathan Leffler
+1  A: 

less somefile

Then press shift F

mhawke
@mhawke I don't quit see how I could use less to redirect to a file output and press Shift+F...
Goyuix
+1  A: 

This isn't tail -- this is progressively copying a file. Look at rsync.

wnoise
A: 

Strictly speaking, you need to write a program to do this, as tail is not specified to work on binary files. There are also buffering issues you probably want to avoid if you want to receive the new "trickled" data as soon as possible.

R..
Well, looking again I saw that you tagged your question gnu-coreutils. So if you know you'll be using the gnu implementation of tail, it's probably binary safe and probably does not have problematic buffering (check and see).
R..