0

Is it possible to create a tar of only the last few lines of a file? Something like this does not seem to be working.

tail abc.xml | tar -zcf bac.tar.gz

I am trying to keep the compressed file size as small as possible. I do also want to transfer it over the network as fast as possible.

shantanuo
  • 31,689
  • 78
  • 245
  • 403
  • Check this [link][1].. [1]: http://stackoverflow.com/questions/516481/add-last-n-lines-of-files-to-tar-zip – monish Oct 10 '11 at 08:51

1 Answers1

1

You can have standard input as the source for tar but what do you want to do? There is no need to create a tar archive for just a single file. You can pipe directly to gzip:

tail abc.xml | gzip - > bac.gz

bac.gz will then contain the last 10 lines of your file (compressed).

But I suspect that your question does not reflect what you want to achieve: you really want to send the last part of the XML file as a compressed gzip file?

Matteo
  • 14,696
  • 9
  • 68
  • 106