wget use gzip header to received compressed output

This test endpoint returns Content-Type: application/json

Without gzip enabled header:

$ wget -qO test https://testendpoint
$ file test
test: ASCII text, with very long lines, with no line terminators
$ du -b test
7307    test

Setting the gzip enabled header:

$ wget --header="accept-encoding: gzip" -qO test.gz https://testendpoint
$ file test.gz
test.gz: gzip compressed data, from Unix
$ du -b test.gz
1694    test.gz

Telling the server that wget can accept gzip compressed content results in 77% reduction in bytes transferred.


get actual size of sparse file

You can see the actual size of a sparse file vs. the apparent size.

# ls -l /var/log/lastlog
-rw-rw-r-- 1 root utmp 684182572 Oct 24 16:56 /var/log/lastlog
# du --apparent-size /var/log/lastlog
668148  /var/log/lastlog
# du -h /var/log/lastlog 
48K     /var/log/lastlog
# ls -ls /var/log/lastlog 
48 -rw-rw-r-- 1 root utmp 684182572 Oct 24 16:56 /var/log/lastlog