Developer on Alibaba Coud: Build your first app with APIs, SDKs, and tutorials on the Alibaba Cloud. Read more ＞
How can I decompress multiple taball compressed files simultaneously on the command line of LinuxDeepin? Before introduction, let's take an example. Suppose we have the following compressed files in the current directory: www.2cto.com $ lsba...
In Linux Deepin, how does one decompress multiple taball compressed files simultaneously on the command line of Linux Deepin? Before introduction, let's take an example. Suppose we have the following compressed files in the current directory: www.2cto.com $ lsbackup1.tar backup2.tar backup3.tar. we need to decompress them all together. what should we do? Let's briefly explain the usage of tar. The tar command is used to read and write files from Tape devices (tar is the contraction of Tape ARchiver ). We can only specify the file name to be compressed or decompressed (for example, tar x myfineonthe. tape ). You can use the-f option to tell tar that the file is not on a tape but in a file. This option only accepts one parameter-the file name of the compressed file. All other (later) parameters are considered part of the compressed file mentioned above. Tar-x-f backup.tar myfile.txt # or use the more common syntax tar xf backup.tar myfile.txt below to return to our previous problem: decompress the backup1.tar backup2.tar backup3.tar files in the current directory. A friend may want to use tar xf *. tar: $ tar xf *. tartar: backup2.tar: Not found in archivetar: backup3.tar: Not found in archivetar: Exiting with failure status due to previous errors what is going on? Shell matches *. tar Replacement. the above line is actually equivalent to tar xf backup1.tar backup2.tar backup3.tar. we can see from our previous usage explanations of tar, the command we use here refers to "decompressing backup2.tar and backup3.tar from the compressed file backup1.tar ". The execution can be successful only when the compressed file "backup1.tar" has a corresponding file name. The solution is simple: extract files from the compressed files one by one. Because we use a UNIX shell (Bash) that can be implemented in a loop: www.2cto.com for tarname *. tar; dotar xf "$ tarname" done describes two basic concepts: loop and for-loop. A loop is a structure used to repeat the internal code before a condition is met. When this condition is met, the cycle is stopped, and the code outside the condition will continue to be executed. A for-loop is a type of loop structure that successively sets a variable as a value in the list and repeats until the list is used up. Here, the for-loop uses the file name matching *. tar as a parameter to repeatedly call and execute tar xf. In this way, the compressed files are automatically extracted one by one. Another common file format is ZIP. The command to decompress the ZIP file is unzip. The same problem exists here: unzip only accepts one option to specify the ZIP file. So we can solve it in the same way: for zipfile in *. zip; dounzip "$ zipfile" done has another method for the unzip command: it can read a shell-like pattern to specify the ZIP file name. To prevent shell from interpreting these styles, use quotation marks. Unzip (rather than shell) will explain *. zip: unzip "*. zip" # You can also use the following clear-cut method: unzip \ *. zip
This article is an English version of an article which is originally in the Chinese language on aliyun.com and is provided for information purposes only. This website makes no representation or warranty of any kind, either expressed or implied, as to the accuracy, completeness ownership or
reliability of the article or any translations thereof. If you have any concerns or complaints relating to the article, please send an email, providing a detailed description of the concern or
complaint, to email@example.com. A staff member will contact you within 5 working days. Once verified, infringing content will be removed immediately.
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:
and provide relevant evidence. A staff member will contact you within 5 working days.