5 ms·
> Say you've just reminded yourself how grep works for the third time this month. Hahaha, exactly. There are some commands that I just don't use enough for the
by hx2a 8y ago
> Say you've just reminded yourself how grep works for the third time this month.
Hahaha, exactly. There are some commands that I just don't use enough for them to properly stick in my mind. Awk is another one. This utility would be helpful for me. Thanks!
- mehrdadn 8y agoIt would come in handy in this situation: https://xkcd.com/1168/ https://xkcd.com/1168/
- fengb 8y agotar actually makes sense with a little mnemonic: tar xzf $file - xtract - ze (actually gzip but fake-accent "the" is more memorable) - file
- mehrdadn 8y agoThe most confusing thing about it for me now (after I eventually decided to learn it and figured out what you mentioned) is the missing dash. Somehow it works both with and without, which makes no sense considering how *nix tools work. Why is it made to be like that?
- jldugger 8y agoBecause it comes from an era before POSIX, when tapes were prevalent and bytes were costly.
- cyphar 8y ago> Why is it made to be like that? The 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 http://man.cat-v.org/unix-6th/1/tp [2]: http://man.cat-v.org/unix-1st/1/tap http://man.cat-v.org/unix-1st/1/tap
- mehrdadn 8y agoWow, thanks!
- junke 8y agoAnd all of this because originally, the Imperial Roman had no punctuation.
- lifthrasiir 8y agoThe same history applies to ps [1] which was introduced in 3rd Edition Unix. [1] http://man.cat-v.org/unix-6th/1/ps http://man.cat-v.org/unix-6th/1/ps
- cyphar 8y agoThough from what I've seen, most people I talk to use the POSIX forms (such as 'ps -ef') and aren't aware that there is a BSD form (such as 'ps aux'). I've always used the BSD form, even though I came to Linux much much later, but I guess which form you use comes from where you learned basic *nix commands. 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.
- lifthrasiir 8y ago> I've always used the BSD form, even though I came to Linux much much later, but I guess which form you use comes from where you learned basic *nix commands. I too use the BSD form but came from the Linux world. Probably it is just a matter of taste (a common answer to everything!). > 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. I argue the ps situation is worse than tar exactly because of that reason. There are three different classes of options in ps, often with slightly different meanings and sometimes with two different long-form options only distinguished by their cases...
- oblio 8y ago
- oneeyedpigeon 8y agoSometimes I dream of a nirvana in which: - 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
- Baal 8y agoNo need for the ‘z’ :)
- majewsky 8y agoYeah, tar is actually pretty simple these days. (At least GNU tar, don't know about other tars.) In 99.9% of cases you only need to know the following: 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.
- talkingtab 8y agotar has trained us so well: "... tar is actually pretty simple these days"
- dingaling 8y agoI still prefer to pipe through a compression program on principle. tar has no good reason to messing around with compression, per the Unix single-function philosophy.
- TremendousJudge 8y agoto people who grew up with archive programs, "making all of this into a single file" and "compressing all of this" is the same thing; requiring two commands is counterintuitive
- craigds 8y agoYou need it if you're processing stdin (curl ...file.tgz | tar xz)
- deleted 8y ago[deleted]
- anonytrary 8y agoFor some reason, I think it would be more funny if the fourth frame was an exact copy of the third (with no text). I think it would be a simpler and less obvious route to the same "punchline".
- amelius 8y agoTar is one example of a command with dubious usage syntax. But how about cp? cp a.txt b/c/d Will this create a new file "b/c/d/a.txt", or will it create a new file "b/c/d"? It's not clear, and depends on the circumstances (if a directory b/c/d exists). There's a flag to control the behavior, but nobody uses it often, so nobody remembers that flag. The best way to assert that "d" is a directory is by adding a trailing slash, but there's no similar way to assert that "d" should be a file. I suspect that there are many bash scripts that are essentially broken because of this problem. Rsync has a similar problem.
- andrei-n 8y agoFor cp you can use -nv. I discovered it two days ago. It displays what will happen without doing it.
- cggarvey 8y ago> tar -h bomb disarmed
- Annatar 8y agohttps://archive.org/download/pdfy-MgN0H1joIoDVoIC7/The_AWK_Programming_Language.pdf https://archive.org/download/pdfy-MgN0H1joIoDVoIC7/The_AWK_P...