| |
Entries tagged as gzipTuesday, February 10. 2009Linux TAR Command
create:
tar -cvf mystuff.tar mystuff/ tar -czvf mystuff.tgz mystuff/ extracting: tar -xvf mystuff.tar tar -xzvf mystuff.tgz testing/viewing: tar -tvf mystuff.tar tar -tzvf mystuff.tgz Note that .tgz is the same thing as .tar.gz Tar "tars up" a bunch of files into one "tar-file" gzip is compression, but only works on one file, so the entire "tarfile" is compressed. Also when creating a tar or cpio backup, never, never, never use an "absolute" path -- you have been warned; also linux tar warns you of this too. The problem is that when you want to unpack, you cannot choose where to unpack to, you will be forced to unpack to the "same" absolute path. When creating a tar or cpio you should change the the appropriate directory and tar from there. Also when creating a tar or cpio it is general good practice to tar up a directory (appropriately named) which contains your files, rather than just the files. This is good courtesy to anyone unpacking your tarfile. If you would like to create a tar file while saving ownership and permissions, add the "p" flag. Creating and saving ownership and permissions: tar -cpvf mystuff.tar mystuff/ tar -cpzvf mystuff.tgz mystuff/ Also take note of the following commands: gzip gunzip cat zcat bzcat bzip2 bunzip2 zgrep bzgrep (cd /mydir && tar -czf - .)|(cd /destdir && tar -xzvf -) tar -czf - . | ssh user@dest "(cd /destdir && tar -xzvf -)" (cd /mydir && tar -czf - .) | ssh user@dest "(cd /destdir && tar -xzvf -)" Errors: If you receive an error such as the following: [root@localhost test]# ssh user@dest "(cd /rh62/home/kernel && tar -czvf - linux-2.2.22.tar.bz2)"|tar -xzvf - Then try leaving off the compression as follows: [root@localhost test]# ssh user@dest "(cd /rh62/home/kernel && tar -cvf - linux-2.2.22.tar.bz2)"|tar -xvf - Spaces in your filenames? Having fun with spaces in the filename or directory name? Here's your answer: find . -type f -name '*jpg' | grep " " | while read REPLY; do Bonus: find . -type f | while read REPLY; do |
QuicksearchSyndicate This Blog |
