Ask Your Question
2

What is the method to gzip the output of "tail -f" into a compressed file?

asked 2021-05-14 11:00:00 +0000

devzero gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2022-04-09 00:00:00 +0000

plato gravatar image

One possible method is to use the following command:

tail -f myfile.txt | gzip > myfile.txt.gz

This command will continuously monitor the file myfile.txt for new lines using tail -f and then pipe the output to gzip, which compresses the data and sends it to the file myfile.txt.gz. The > operator redirects the compressed output to the file.

Note: If you want to remove the uncompressed file after the compression, you can use rm myfile.txt after the above command. However, be careful when removing files, as it may result in data loss or unexpected consequences.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2021-05-14 11:00:00 +0000

Seen: 1 times

Last updated: Apr 09 '22