6 ms·
In my project, I maintain 3 documents. The first one is a similar list of basic linux knowledge that people should learn when arriving on the project. The secon
by reacweb 9y ago
In my project, I maintain 3 documents. The first one is a similar list of basic linux knowledge that people should learn when arriving on the project. The second is "UnixTipsAndPitfalls" where people should add new entries when they encounter usefull commands. The third one is about tar.
- needz 9y agoYou should make github gists of these.
- ivanhoe 9y agoOver 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.
- Sean1708 9y ago> The third one is about tar. Why do people have such a difficult time with tar? The only tar commands I've ever needed (or seen other people need) are `tar cf ...` or `tar xf ...` (occasionally I'll need to chuck a z in there if the file is/needs to be gzipped), are other people just using far more complex tar commands than I am?
- eitland 9y agoBecause people assume they should RTM and if memory serves me right it is a whole lot more confusing than your post :-)
- Sean1708 9y agoDoesn't look any more complex than most man pages: https://linux.die.net/man/1/tar https://linux.die.net/man/1/tar
- eitland 9y agoPart of my point: most of them are complex and to a big degree unnecessarily complex.
- michrassena 9y agoI agree and wish distro maintainers could make some changes. I would love to use manual pages, but instead I search the Internet first. If every manual had a section with most-common examples, it would help immensely. You could just type 'manexamples tar' and it would print out tar cvf somedir filename.tar create an archive from somedir and store it in filename.tar tar xvpf filename.tar extract the contents of filename.tar and scatter them around your home directory Instead of getting examples that I might use, when I visit a man page, I get a wall of text 926 lines long, describing every possible option, including GNU option styles, or some truncated mess telling me to read the info pages. Of course, it's appropriate that all this information is included somewhere in the manual. I just think the common use cases should be first. Does anyone need a man page for 'ls' that starts off describing how to list inode numbers and SELinux labels?