by fengb · 8y ago · 0 comments
tar xzf $file
- xtract
- ze (actually gzip but fake-accent "the" is more memorable)
- fileThe history of tar is quite long, but the short version is that it was first released as part of 7th edition Unix. It was a successor to tp[1] which was introduced in 4th edition Unix, which was a successor to tap[2] which was released in 1st edition Unix. In 1st edition Unix (as far as I could tell from looking through the man pages), no command had '-abc'-style flag support at all (so tap's semantics made sense). I imagine that quite a few users did something like 'alias tap=tp' and 'alias tp=tar' when upgrading, and so CLI backwards compatibility was required. As a result, everyone learned to use tar that way and it stuck.
[1]: http://man.cat-v.org/unix-6th/1/tp [2]: http://man.cat-v.org/unix-1st/1/tap
Make is another famous victim of this:
> Why the tab in column 1? Yacc was new, Lex was brand new. I hadn't tried either, so I figured this would be a good excuse to learn. After getting myself snarled up with my first stab at Lex, I just did something simple with the pattern newline-tab. It worked, it stayed. And then a few weeks later I had a user population of about a dozen, most of them friends, and I didn't want to screw up my embedded base. The rest, sadly, is history.
Bad example, since tar still works with a dash:
tar -ztvf foo.tar.gz
> Make is another famous victim of this:Now that is a much better example.
I guess the lack of '-' with tar is more apparent because POSIX didn't create a different syntax, and so most people omit the '-' for terseness -- while with ps it would require learning a different syntax.
- all unix commands support both short and long options
- option letters/names are, at least to a much greater extent than currently, common across different commands
tar caf $archive $file... to create
tar xf $archive to extract
"x" will automatically recognize the compression format, and "ca" will automatically infer the desired compression format from the extension in $archive, e.g. tar caf backup.tar.xz /home/user
makes an xz-compressed tarball.