Skip to content

Commit 1b4707c

Browse files
committed
Improve gzip info, htop.
1 parent 1dbc374 commit 1b4707c

File tree

2 files changed

+47
-12
lines changed

2 files changed

+47
-12
lines changed

compression.md

+44-11
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,13 @@ To a dir:
6464

6565
ZIP every file in cur dir to file.zip
6666

67-
#tar tar.gz tgz tar.bz2 tb2
67+
#tb2
6868

69-
Name origin: tape archive.
69+
#tgz
70+
71+
#tar
72+
73+
Name origin: `Tape ARchive`.
7074

7175
The tar *format* is specified by POSIX 7 together with the `pax` utility: <http://pubs.opengroup.org/onlinepubs/9699919799/utilities/pax.html#tag_20_92>
7276

@@ -83,10 +87,6 @@ It is a popular option to transform directories in to files in Nix systems, as t
8387

8488
Since tar offers no compression, it is often coupled with `gz` and `bz2`: those are files compressors.
8589

86-
`.gz` gives similar compression ration as `.zip`
87-
88-
`.gz2` gives more compression than `.gz` (30% for ROMs), but is much slower to make, and you can't extract individual files easily.
89-
9090
tar end compressions are used so commonly together that shorthand extensions exist for them:
9191

9292
- `tgz` == `tar.gz`
@@ -127,25 +127,33 @@ Extract:
127127
tar vxzf "$F".tgz
128128
tar vxjf "$F".tbz
129129

130+
#zlib
131+
130132
#gzip
131133

132134
#gunzip
133135

134136
#gz
135137

136-
gzip files.
138+
Extension: `gz`.
139+
140+
Library name: zlib, GNU.
141+
142+
Popular wrapper: `gzip`, and `gunzip` to unzip.
137143

138144
Vs zip:
139145

140146
- Completely different file types.
141147

142-
- Both are use the DEFLATE algorithm: <https://en.wikipedia.org/wiki/DEFLATE>, and therefore have very similar compression ratios and speeds.
148+
- Both use the DEFLATE algorithm: <https://en.wikipedia.org/wiki/DEFLATE>, and therefore have very similar compression ratios and speeds.
149+
150+
- The zlib library does not focus on directories: only single files. For this reason it is commonly used together with `tar` which only packs directories into a file. For convenience however, the command line executable can deal with `.tgz` files.
143151

144-
- gzip seems to have very one dominant implementation: GNU, so that gzip can refer to either the utility or format used by that utility.
152+
- gzip seems to have very one dominant implementation: GNU zlib, so that gzip can refer to either the utility or format used by that utility.
145153

146-
zip has many implementations: WinRAR, WinZip on closed source on Windows, Info-ZIP and libzip open source, Info-ZIP being the default one present on Ubuntu 12.04. Therefore the term zip usually onlre refers to
154+
zip has many implementations: WinRAR, WinZip on closed source on Windows, Info-ZIP and libzip open source, Info-ZIP being the default one present on Ubuntu 12.04. Therefore the term zip usually only refers to the file format.
147155

148-
If a file is only gz but not tgz you cannot use tar to extract it
156+
If a file is only `.gz` but not `.tgz` you cannot use tar to extract it.
149157

150158
Create `a.txt.gz` and `rm` `a.txt`:
151159

@@ -155,6 +163,31 @@ Extract `a.gz` and erase it if successful:
155163

156164
gunzip a.gz
157165

166+
`.gz` all files under given directory recursively individually. Remove each original:
167+
168+
gzip -r .
169+
170+
##Hardlinks
171+
172+
##Keep original
173+
174+
Does not work if the file has any hard links, probably because that would not reduce memory usage as it breaks the hardlink. AKA: tries to be too smart and annoys us to hell!
175+
176+
Workaround: keep the original on the operations: <http://unix.stackexchange.com/questions/46786/how-to-tell-gzip-to-keep-original-file>
177+
178+
Workarounds: `-c` outputs to stdout:
179+
180+
gzip -c a > a.gz
181+
182+
Read input from stdin:
183+
184+
gzip < a > a.gz
185+
186+
And finally, `gzip` 1.6 (2013) has the `-k, --keep` option:
187+
188+
gzip -k a
189+
gzip -kr .
190+
158191
#RAR
159192

160193
Proprietary `Roshal ARchive`, after it's creator Eugene Roshal.

utils.sh

+3-1
Original file line numberDiff line numberDiff line change
@@ -2579,7 +2579,9 @@
25792579

25802580
# Better top.
25812581

2582-
# Possible to scroll down.
2582+
# More options, and much easier to use: self explanatory interface.
2583+
2584+
# Possible to scroll down the process list.
25832585

25842586
##free
25852587

0 commit comments

Comments
 (0)