GREPWISE

Remember tar flags for good (a mnemonic)

Remember tar as c/t/x plus z and f. Create, list, and extract one archive and the flags stop feeling random.

Remember tar flags for good (a mnemonic)

HOOK - 0-3s

tar is five letters of muscle memory, not a quiz.

PROBLEM - 3-10s

Most tar mistakes are not technical. You just forget whether this time was create, list, or extract, then shuffle letters until the archive opens.

SOLUTION - 10-40s

Use the mnemonic: create, table of contents, extract. Add z for gzip, f for file.

tmp=$(mktemp -d); mkdir -p "$tmp/demo" && printf 'alpha\n' > "$tmp/demo/a.txt" && printf 'beta\n' > "$tmp/demo/b.txt"
cd "$tmp" && tar -czf demo.tgz demo                              # create gzip archive file
tar -tzf demo.tgz                                                 # list contents
mkdir out && tar -xzf demo.tgz -C out                             # extract into out/
[list]
demo/
demo/b.txt
demo/a.txt
[extracted]
out/demo/a.txt: alpha
out/demo/b.txt: beta

PAYOFF - 40-50s

Once the letters map to verbs, the order stops being mystical. czf builds an archive. tzf inspects it. xzf unpacks it.

CTA - 50-55s

Say the verbs once before you type the flags.

exit 0

#tar#bash#linux#selfhosting

❯ exit 0

cd ..