Thứ Sáu, 31 tháng 5, 2013

Linux and Unix tar command



Note: A ".tar" file is not a compressed files, it is a collection of files within a single file uncompressed. If the file is a .tar.gz ("tarball") or ".tgz" file it is a collection of files that is compressed. If you are looking to compress a file you would create the tar file with the z option or create the file and then gzip the file.

Example Creating a tar file for ADMIN Folder:
tar -cvf admin.tar ADMIN

Creating a tar file
tar -cvwf file.tar myfile.txt
In the above example, the system would create a tar named file.tar in the directory you currently are in. Wildcards could also be used in this command, for example: tar -cvwf file.tar *.txt would archive all txt files in the current directory.

tar -cvwf home.tar home/
In the above example command the system would create a tar file named home.tar containing the home directory and place that file in the current directory.

Extracting the files from a tar file
tar -xvwf myfile.tar
In the above example command the system would unarchive (untar) the myfile.tar file into the current directory.

tar -xvwzf myfile.tar.gz
In the above example command the system would unarchive (untar) the myfile.tar.gz file in the current directory.
Tip: There is no "untar" Linux and Unix command. The tar command is used to create and extract tar files.

Creating a tarred file that is compressed
tar -cjvf test.tbz home/
Adding the j option to the tar command enables tar to compress files and directories using bzip. In the above example the home directory and all its subdirectories are added to the compressed test.tbz file.

Listing the tar contents without extracting any of the files
tar -tvf myfile.tar
In the above example, the tar command will list the contents of the .tar file without extracting any of the files. Adding the z or j option will also allow you to view the files of a bzip

Không có nhận xét nào:

Đăng nhận xét

Học lập trình web căn bản với PHP

Bài 1: Các kiến thức căn bản Part 1:  https://jimmyvan88.blogspot.com/2012/05/can-ban-lap-trinh-web-voi-php-bai-1-cac.html Part 2:  https://...