I am maintaining some old scripts and I came across this:
tar -cvf - ${files} | gzip -n -c | openssl ...
Is there any practical difference between this and a more compact, without the "-n" to gzip? Is there some other way to pass "-n" to gzip in tar
command?
tar -cvzf - ${files} | openssl ...
This is on Linux 3.0.101-0.47.71-default. I would expect a slight performance improvement but my concern is not causing a change downstream.
old
tar
didn't have gzip compression built in. On anygzip
I know,n
has no meaning when fed throughstdin
. Aside, of course from setting the compression timestamp in the gzip data to 0.I doubt the usefulness of that option, to be honest – on anything I could test, the size remained the same. That is correct behaviour – the header (as specified in RFC 1952, Sec. 2.2) simply has a 4B timespec in seconds since epoch – if you set it to 0, it implies "no timespec saved". So, unless you need to not let the receiver of the gzip'ed data know when it was compressed,
-n
has no benefit. (There might be security benefits stemming from omission of such time stamps if you've got some authentication scheme that is based on unknown timing, eg. Session IDs generated from the time since booting a device, but to be frank, I'd rather worry about plugging those security holes than setting a timestamp to zero.)