scp: How to copy only the last 10% of a file?

I have a relatively large log file (46M) on a vServer, of which I'm only interested in the most recent part.

How can I download only the last 10% of the file?

The server is running Debian and I'm using Ubuntu locally.


Solution 1:

First get the size of the remote file in bytes:

$ ssh user@host 'stat -c%s FILENAME'    
50000

Calculate 10% of that number, and copy the last ten percent:

$ ssh user@host 'tail -c 5000 FILENAME' > DESTINATION