Command Line tips-how to decompress multiple files at a time

Source: Internet
Author: User
Command Line tips-how to decompress multiple files at a time-Linux general technology-Linux programming and kernel information, the following is a detailed description. As we all know, the tar command can only accept one file name as a parameter, that is, the tar command itself can only decompress one file at a time. If there are many .tar.gz files in a directory, it is obviously troublesome to decompress them one by one. Can I solve them all by one command? The answer is yes.

We can implement this through the for in loop statement. The principle is that the archive file names to be extracted will be highlighted one by one, and the tar can reference these variables one by one through the loop statement. The complexity is actually very simple, and I will not break it down. The specific commands are given below.

Decompress all .tar.gz files in the current directory: for ARK in./* .tar.gz; do tar xvf $ ARK; done

The principle is as mentioned above. Assign the file names of all .tar.gz files in the current directory to the variable ARK one by one and let tar reference the ARK variable.
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.