review tar
these two days I spent some time reading the manual of GNU tar (not BSD version, through my mac's shell is BSD), and get some usefull insights about tar:
1. tar is just a archiving tools , which means you can put many files together for the convinent of other operation. 8 operations are provided , which are Arctudx, and tons of options are provided
2. when you want to archieve files , use tar -cf new_file.tar file1 file2 filen , when you want to compress files after archive , add option z (for gzip compress) or j( for bzip2 compress), when you want to compress but not archieve , close this website and go for manual of gzip or bzip or pbzip2.......
3. when you want to extrace files, use tar -xf new_file.tar , when you want to extract files which is compressed , add z or j option or do nothing
4. you can use A operation to cancatate two tar files, tar -Af file1.tar file2.tar
5. and use -r operation to append a fs file to a tar file, tar -rf file1.tar normalize_file.xxx
6. want to know the content of the tar file ? just tar -tf new.tar
7. -u, --update, only append files that are newer than the existing in archive, so if you want to refresh a file , delete it and append it again, use
tar uf new.tar 1.txt 2.txt 3.txt to update a file , use tar df new.tar 2.txt to delete a file
here is the eight operations
options are like backup (--backup, --suffix), overwrite or keep (-k for keep old files), exclude some pattern( --exclude) or other , just query manual when you need use it
now, you can use tar to copy a whole directory to another place ' cd sourcedir ; tar cf - . | (cd destdir ; tar xf -)'
ps: some pictures about different compress ways