15 ms·
Over years I've heard a lot of complains on tar being hard to use, but in real-life I really ever had to use only these two commands: tar zcvf and tar zxvf. It'
by ivanhoe 9y ago
Over years I've heard a lot of complains on tar being hard to use, but in real-life I really ever had to use only these two commands: tar zcvf and tar zxvf. It's actually quite easy to remember: tar Zip Compress Verbose File, and tar Zip eXtract Verbose File.
- liveoneggs 9y agoadd 'tar r' and 'tar u' to your arsenal.
- emmelaich 9y agoIn about 40 years of using Unix I have never used r or u.
- liveoneggs 9y agoboth seem fairly important in the 40-years-ago world concerning the 't'(ape) part of tar but okay. I use them frequently as an "rsync"-ish into the archive file, which I can then use to take point-in-time snapshot/backups.
- reacweb 9y agoYes. I also suggest to use tar instead of the dangerous cp -r: tar c -C src . | tar x -C dst. It works over ssh connections (ssh -C for compression) and is a good training of tar syntax.
- AstralStorm 9y agoIt is also quite slow. For such moves rsync works much better.
- nerdponx 9y agoIt's even easier than that! Less memorization, more understanding. You can think of Tar arguments as either subcommands or options. The dashes are optional The "subcommands" are x (extract), c (create), t (list), among others. The "options" are f (read from named file rather than stdin), v (verbose mode), and z (run gzip on the archive before processing). The fact that these options can be written without leading dashes, and all smashed together in a single argument, is legacy silliness for saving a few keystrokes. Don't confuse yourself with it, and don't confuse other people by teaching it to them, instead of teaching them how to actually use the command (which is really not hard at all). So when I write Tar commands, I like to think along these lines. Instead of "tar zcvf foo.tar.gz", I write "tar -c -zv -f foo.tar.gz". After doing that about 3 times, it all sank in. Nowadays I'm much more intimidated by Git than Tar. In the version of tar on the machine I'm posting from (GNU tar 1.27.1), this structure is obvious from right there in the man page: SYNOPSIS Traditional usage tar {A|c|d|r|t|u|x}[GnSkUWOmpsMBiajJzZhPlRvwo] [ARG...] UNIX-style usage tar -A [OPTIONS] ARCHIVE ARCHIVE tar -c [-f ARCHIVE] [OPTIONS] [FILE...] tar -d [-f ARCHIVE] [OPTIONS] [FILE...] tar -t [-f ARCHIVE] [OPTIONS] [MEMBER...] tar -r [-f ARCHIVE] [OPTIONS] [FILE...] tar -u [-f ARCHIVE] [OPTIONS] [FILE...] tar -x [-f ARCHIVE] [OPTIONS] [MEMBER...]
- jcelerier 9y agoYou can just do `tar caf` and `tar xaf`. It detects the archive format automatically (and I personnally find it easier to remember: "compress-as-fuck" and "extract-as-fuck").
- milankragujevic 9y agowow thanks for that :)
- GlennS 9y agoOver years I've heard a lot of complaints on tar being hard to use, but in real-life I really ever had to use only these two commands: zip and unzip. It's actually quite easy to remember: zip, and unzip.