The use and learning of TAR commands

Source: Internet
Author: User

The 1.tar command (Tape Archive command) file extension includes. tar.gz. tar.bz2 Z for gzip J for bZIP

2. Unzip the archive file TAR-XVZF. tar.gz tar-xvjf. tar.bz2

3. Extract the files to a specified directory tar-xvzf. Tar.gz-c/opt/folder Note: If the directory is to exist, the error will be

4. Remove individual files tar-xz-f. tar.gz "./new/cde.txt" "./new/c.txt" or tar-xz-f. tar.gz--wildcards "*/c.txt"

5. List the contents of the archive file tar-tz-f. tar.gz tar-tz-f. tar.gz | grep abc.txt tar-tz-f. tar.gz | Less abc.txt

6. Archive does not compress TAR-CVF Abc.tar./new

7. Archive and Compress Tar-cvzf abc.tar.gz./new

8. Before adding a file confirm that the file is added to the archive only when the user enters Y tar-czw-f a.tar.gz./new/*

9. To add files to a normal archive file, the file cannot be added to the archive that has been compressed. R tar-rv-f Abc.tar Abc.txt

10. Add the file to the compressed archive (tar.gz tar.bz2) unzip the archive file to add the file to the archive and re-compress gunzip a.tar.gz tar-rf a.tar./path/to/file gzip A.tar use bzip2 and bunzip2 for bzip files respectively

11. Backup by Tar for fixed-time backup directory The TAR command can be implemented by cron scheduling to implement such a backup tar-cvz-f archive-$ (date +%y%m%d). tar.gz./new/

Using Cron to run the above command will keep a backup file similar to the following name: ' Archive-20150218.tar.gz '.

12. Validate when creating an archive W can be used to verify only non-compressed archive files after creating an archive file

Reference documents:

Https://linux.cn/article-5167-1.html

The use and learning of TAR commands

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.