Zip rar shell command

Source: Internet
Author: User
Tags unpack

1. Compress the MyData directory below the/home directory to Mydata.zip
Zip-r Mydata.zip MyData #压缩mydata目录
2. Unzip the mydata.zip under the/home directory into the Mydatabak directory
Unzip mydata.zip-d Mydatabak
3, the home/home directory below the ABC folder and 123.txt compression becomes abc123.zip
Zip-r abc123.zip ABC 123.txt
4. Extract the Wwwroot.zip from the/home directory directly into the/home directory
Unzip Wwwroot.zip
5, the Home/home directory under the Abc12.zip, Abc23.zip, abc34.zip simultaneously extracted to the/home directory
Unzip Abc\*.zip
6. View the contents of the wwwroot.zip inside the/home directory
Unzip-v Wwwroot.zip
7. Verify that the wwwroot.zip under the/home directory is complete
Unzip-t Wwwroot.zip
8. Unzip all the files inside the/home directory under Wwwroot.zip to the first level directory
Unzip-j Wwwroot.zip

Main parameters

-C: Results that will be decompressed
-L: Displays files contained within the compressed file
-P: Similar to the-c parameter, the extracted results are displayed on the screen, but no conversions are performed
-T: Check that the compressed file is correct
-U: Similar to the-f parameter, but other files in the compressed file are extracted to the directory in addition to updating the existing file
-V: Show detailed information when performing Yes
-Z: Show only notes text for compressed files
-A: Necessary character conversions for text files
-B: Do not convert text files to characters
-C: File names in compressed files are case-sensitive
-j: does not handle the directory path of compressed files
-L: Change all file names in the compressed file to lowercase
-M: Send output to more program processing
-N: Do not overwrite the original file when decompressing
-O: Do not ask the user first, overwrite the original file after unzip execution
-P: Password option with zip
-Q: Do not display any information when executing
-S: Converts white space characters in file names to baseline characters
-V: Keep the file version information of the VMS
-X: Uid/gid The original file while decompressing

Tar Pack and unpack

Syntax: tar [main option + Secondary options] file or directory
When using this command, the main option is required, and it tells Tar what to do, auxiliary options are auxiliary and can be used.

Main options:

-C create-r add/replace-t list-u update-x Extract

Auxiliary options:

Option to package or unpack common options and packages only

Common options:

-B #: #为一数字, each I/O block uses a # byte record, default 512

-F: Archive location

-V: Fine-Report The file information processed by tar. Without this option, TAR does not report file information.

-W: Every step requires confirmation

Unzip common options:

-K: Save existing files without overwriting
-M: When restoring files, set the modification time of all files to now
-O: The entry is standard output, not restored to disk
-P: Restore permissions (including ACLs, authors, file tags)

Example 1: Pack all the subdirectories that include it in the/home directory, and the package file name is Usr.tar.
$ tar cvf usr.tar/home
Example 2: Package all subdirectories under the/home directory, and compress them, the file name is usr.tar.gz.
$ tar czvf usr.tar.gz/home
Example 3: Restoring and unpacking a compressed file usr.tar.gz.
$ tar xzvf usr.tar.gz
Example 4: View the contents of the Usr.tar backup file and display it on the display in Split-screen mode.
$ tar TVF Usr.tar | More
To back up a file to a specific device, simply use the device name as the backup file name.
Example 5: The user creates a backup file on the floppy disk of the/DEV/FD0 device and copies all the files in the/home directory to the backup file.
$ tar Cf/dev/fd0/home
To restore files from your device's disk, use the XF option:
$ tar xf/dev/fd0

4. rar file Decompression and compression

RAR and Unrar commands need to install themselves, you can directly through the brew installation, if you do not know the Brew installation command, you can see the "Mac installed similar Apt-get Package Manager--Homebrew", the following is another simple installation method

1. Download the corresponding RAR version on Mac

Http://www.rarlab.com/download.htm

2. Unzip the downloaded rarosx-5.4.0.tar.gz with the tar name and the version may be updated

Tar xzvf arosx-5.4.0.tar.gz. #解压到当前目录

3. Install RAR and Unrar commands

sudo install-c-o $USER rar/usr/local/bin/# installation rar
sudo install-c-o $USER unrar/usr/local/bin # installation Unrar

If the installation fails, you can see if the/usr/local/bin directory is not a soft link that exists with RAR or Unrar

4. Using RAR and Unrar compression and decompression files

RAR and Unrar file parameters are also many, it is not introduced, directly in the Ternimal to execute the corresponding command can see all the parameter options, the following list of several commonly used

Extract files: Unrar x Test.rar
Compressed files A and b:rar a after compression. rar a B

Reference Documentation:

Http://www.cnblogs.com/davidxie/archive/2012/11/23/2784646.html

Http://www.cnblogs.com/heiniuhaha/archive/2011/11/30/2269503.html

Zip rar shell command

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.