Linux file management-compression and decompression command: tar format: tar option file directory list function: Package and back up the file directory www.2cto.com option: -c create a new archive file-r append a file to the end of the archive file-x extract the file from the archive file-O extract the file... capital
Linux file management-compression and decompression command: tar format: tar option file directory list function: Package and back up the file directory www.2cto.com option: -c create a new archive file-r append a file to the end of the archive file-x extract the file from the archive file-O unbind the file to the standard output-v process and output the relevant information-f perform operations on common files-z calls gzip to compress the archive files, when used with-x, gzip is called to complete decompression-Z is called to compress the archive file, and compress is called to complete decompression when used with-x. example 1: Purpose: run the command # tar-cvf/mnt/lgx/a1.doc to package a file with the extension .tar. 2: Purpose: use tar to uncompress the package. command: # tar-xvf/mnt/lgx/a1.doc.tar additional instructions: In general, tar packaging and gzip (compression) are often used in combination to achieve better results. The method is as follows: first use tar for packaging, for example, # tar-cvf/mnt/lgx/a1.doc (a1.doc.tar file). example: # gzip/mnt/lgx/a1.doc.tar (a1.doc.tar.gz file) example 3: objective: to decompress the a1.doc.tar.gz file Method 1: # gzip-dc/mnt/lgx/a1.doc.tar.gz (aa1.doc.tar file) # tar-xvf/mnt/lgx/a1.doc.tar (paia1.doc) these two commands can also use the pipeline function to combine the two commands into one: # gzip-dc/mnt/lgx/a1.doc.tar.gz | tar-xvf Method 2: use the gzip decompression function provided by tar to automatically call # tar-xzvf/mnt/lgx/a1.doc.tar.gz after tar packaging, compres can also be used S command compression (note: gzipis more efficient than compress compression, and a file named .tar. Z can be decompressed in the format of "uncompress file name" when unpacking, and then decompressed with "tar-xvf file name. You can also call "tar-Zxvf file name" to unpack the package. The gzip and gunzip commands under Red Hat Linux 9 use gzip to compress the file. at the shell prompt, enter the following command: the gzip filename file will be compressed and saved as filename.gz. To expand the compressed file, type the following command: gunzip filename.gz will be deleted, followed by filename. You can use the gzip command to process multiple files and directories at the same time by listing them one by one and using the space interval: the command above gzip-r filename.gz file1 file2 file3/usr/work/school sets the contents of file1, file2, file3, and/usr/work/school directories (assuming this directory exists) compress the file and put it in the filename.gz file. Tips: For more information about the two commands, enter man gzip and man gunzip at the shell prompt to read the manual pages of The gzip and gunzip commands. Zip and unzip use zip to compress the file. at the shell prompt, enter the following command: zip-r filename.zip filesdir. In this example, filename.zip indicates the file you created, filesdir indicates the directory where you want to place the new zip file. The-r option specifies that you want to recursively include all files included in the filesdir directory. To extract the content of a zip file, type the following command: unzip filename.zip you can use the zip command to process multiple files and directories at the same time by listing them one by one and using the space interval: the command above zip-r filename.zip file1 file2 file3/usr/work/school puts the contents of file1, file2, file3, and/usr/work/school directories (assuming this directory exists) compress the file and put it in the filename.zip file. Tips: For more information about the two commands, enter man zip and man unzip at the shell prompt to read the manual pages of the zip and unzip commands. At the shell prompt, the archive tar file is a collection of several files and/or directories in one file. This is an excellent path for creating backups and archives. Tar uses the following options: *-c-create a new archive. *-F-when used together with the-c option, the created tar file uses the file name specified by this option. when used together with the-x option, the archive specified by this option is removed. *-T-displays the list of files included in the tar file. *-V-displays the file archiving progress. *-X-extract files from the archive. *-Z-use gzip to compress the tar file. *-J-use bzip2 to compress the tar file. To create a tar file, type tar-cvf filename.tar directory/file in the previous example. filename.tar represents the file you created, and directory/file represents the files and directories you want to put into the archive file. You can use the tar command to process multiple files and directories at the same time by listing them one by one and using spaces: run the tar-cvf filename.tar/home/mine/work/home/mine/school command to put all the files in the work and school subdirectories in the/home/mine directory into the current directory. A new file named filename.tar. To list the content of the tar file, type tar-tvf filename.tar to extract the content of the tar file. type tar-xvf filename.tar to not delete the tar file, however, it copies the unarchived content to the current working directory and retains any directory structure used by the archive file. For example, if the tar file contains a file named bar.txt which is included in the foo/directory, extracting Archive files will create the foo/directory in your current working directory, which contains the bar.txt file. Remember that tar does not compress files by default. To create a file that uses tar and bzip to archive and compress, use the-j option: tar-cjvf filename. tbz file. the tar file compressed with bzip2 has the. tbz extension. However, sometimes users use the tar.bz2 extension to archive their files. The preceding command creates an archive file and compresses it into a filename. tbz file. If you use the bunzip2 command to decompress the filename. tbz file, the filename. tbz file will be deleted, followed by the filename.tar file. You can also use a command to expand and release the archive bzip tar file: tar-xjvf filename. to create a file archived and compressed with tar and gzip, use the-z option tar-czvf filename. according to conventions, tgz files use gzip to compress tar files. tgz extension. This command creates an archive file filename.tar and compresses it into a filename. tgz file (the file filename.tar is not retained ). If you use the gunzip command to decompress the filename. tgz file, the filename. tgz file will be deleted and replaced with filename.tar. You can use a single command to expand the gzip tar file: tar-xzvf filename. tgz. enter the command man tar to read the details of the tar command.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.