Linux rar command compression and decompression detailed

Source: Internet
Author: User
Tags rar stdin

Example 1: Add a file or directory to a compressed archive, using the a command. For example, add the file files1 to Abc.rar, use the A or M command, a command to add the File1 file to the Abc.rar file to keep the original file1 files unchanged, M command to move the file1 file into the File1.rar files ( When the compression is complete, the original file1 file is deleted, note: The M command is only for the file operation)
$rar a Abc.rar file1

Note: If the Abc.rar file does not exist at this time, will create the Abc.rar file, if the Abc.rar files already exist, the file1 files will be compressed into the Abc.rar file, if there is a Abc.rar files in the File1 archive, the File1 file will be updated. And the original File1 file still exists in the current directory, to move the file1 file to File1.rar, use the M command, which is also available for the directory.
Note: If you enter only the "rar a File1.rar" command instead of the file name or directory name, all the files and folders in the current directory will be compressed into the File1.rar document. Pay attention to this point.

Example 2: Extract the contents of the Abc.rar file, you can use the E or X command, assuming that the Abc.rar directory has a file named File1 and a directory named Test, the test directory has a file named File2,
$rar e Abc.rar

Note: Using the e command, the File1 file in Abc.rar is extracted to the current directory along with the File2 file in the test directory. If you want to keep the directory structure in the Abc.rar directory, use the x command.
$rar x Abc.rar

Description: The File1 file and the test directory are extracted to the current folder.

Example 3: Add comments for the entire compressed file
$rar C Abc.rar

Note: When you enter this command, the bottom of the screen is displayed
Processing archive test.
Rarreading comment from stdin

And there is a cursor blinking, enter the comment information from the position where the cursor blinks, enter the end input by pressing CTRL+D

Example 4: Add a comment to a single file in a compressed file, using the CF command. If you want to add a comment to the file1 file in the Abc.rar archive now
$rar CH Abc.rar file1

At the bottom of the screen, you'll see
Reading comment for abc.rar:file1 from stdin

Blinking from the cursor enter the comment you want to add for file1, Ctrl+d end input

Example 4: Write a note of the entire file to a file, using the CW command. Join to write comments for Abc.rar to the Test.txt file
$rar CW Abc.rar Test.txt

Note: If a file named Test.txt is not present in the current directory, a file named Test.txt is created on its own, and the Abc.rar comment is written to the Text.txt file, and if a file named Text.txt already exists in the current directory, you are prompted to overwrite the file that already exists, as If you select Yes or all, the contents of the test.txt are emptied, and the Abc.rar comments are written to the Text.txt file.

Example 4: Deleting a file or directory in a compressed archive, using the D command. For example, to delete the File1 file in the Abc.rar archive.
$rar D Abc.rar file1

Note: This command removes the File1 file from the Abc.rar archive and is also valid for the directory.

The above is the usual compression and decompression command,< options > Part of the use is no longer introduced, please try it yourself.

Unzip the command Unrar using:

$unrar--help

Usage: Unrar <command>-<switch 1>-<switch n> <archive> <files...>
< @listfiles ...> <path_to_extract\>

< commands >
E Unzip the file to the current directory
L[T,B] List Compressed Document information [technical, bare]
P print files to standard output
T test compression I'm Russian
V[T,B] List details of compressed documents [Technical,bare]
X unzip the file to the full path


The following are < options > sections, omitted.

Unrar commands and RAR have the same effect, you can see that Unrar contains only a part of the RAR command, so the use of RAR can do all the operation.

Linux rar command compression and decompression detailed

Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.