'jar' better than 'zip' ?
By Katsumii-Oracle on Jan 24, 2013
I recently learned that 'jar' can write to stdout. I think this tends to be overlooked for 3 reasons.
- 'jar' command line help doesn't suggest so unlike 'tar'.
- 'man jar' not possible on many installations.
- '-' doesn't mean stdout for 'jar' command.
Where 'man jar' runs, it shows below:
To copy directories, first compress files in
stdout, then extract from
-f option from both
jarcommands):% (cd dir1; jar c .) | (cd dir2; jar x)
Firstly, I think this command will add MANIFEST to destination. One can do:
$ (cd dir1; jar cM .) | (cd dir2; jar x)
Secondly, I think better example would be over the network transfer.
This is what I do on Windows with PuTTy command line tool.
I can do same with 'tar.gz' but when I want to send this to someone, *.zip is handier.
$ plink myid@myserver 'cd data/ && jar cM *.txt *.csv' > allData.zip
So, although 'jar' and 'zip' creates archive in same format, jar is better for 2 reasons.
- 'zip' doesn't take directory name as argument
- No support for stdout. 'man zip' says there is some support but that's not for 'file system' archive.