In the Linux system, the files can be decompressed on the Deepin command line. You can also decompress multiple tarball files at the same time using the Deepin command line. So how do you decompress multiple compressed files in Deepin at the same time in Linux?
$ ls
backup1.tar backup2.tar backup3.tar
We need to unpack them all together, how?
Let's briefly explain the usage of tar. The tar command was originally used to read and write files from tape devices (tar is the abbreviation of Tape ARchiver). We can only specify the name of the file to be put into the compressed file or to be extracted (eg 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 accepts only one parameter —— the filename of the compressed archive. 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 below
tar xf backup.tar myfile.txt
Now go back to our previous question: Unzip the backup1.tar backup2.tar backup3.tar file in the current directory. There may be friends who want to use tar xf *.tar, let's take a look at its execution results:
$ tar xf *.tar
tar: backup2.tar: Not found in archive
tar: backup3.tar: Not found in archive
tar: Exiting with failure status due to previous errors
What is going on? The shell replaces *.tar by matching the file name. The above line is actually equivalent to:
tar xf backup1.tar backup2.tar backup3.tar
From our previous explanation of the usage of tar The meaning of the command we use here is “ extract backup2.tar and backup3.tar” from the compressed file backup1.tar. Only if there is a corresponding file name in the compressed file backup1.tar can it be executed successfully.
Solution: Unzip the files one by one from the compressed file.
We are using a UNIX shell (Bash) that can be implemented in a loop:
for tarname in *.tar; do
tar xf “$tarname”
done
Let's talk about the basic concepts of loops and for-loops. A loop is a structure used to repeat its internal code before a certain condition is met. When the condition is met, the loop stops and its external code continues to execute. The for loop is to set a variable to each value in a list, and repeat the loop structure until the list is exhausted.
Here, the for-loop will repeatedly call tar xf with the file name matching *.tar as a parameter. This will decompress the compressed file one by one automatically.
Another very common file format is ZIP. The command to extract ZIP files is unzip. Here is the same problem: unzip only accepts an option to specify a ZIP file.
Can be solved in the same way:
for zipfile in *.zip; do
unzip “$zipfile”
done
There is another way to do this with the unzip command: it can read a shell-like pattern to specify the ZIP file name. To prevent the shell from interpreting these styles, you need to use quotes .unzip (not the shell) to explain *.zip:
unzip “*.zip”
# The following seems clearer:
unzip \\*.zip
The above is a tutorial on how to extract multiple compressed files in Deepin at the same time in LinuxLinux. You don't need a tutorial to use this tutorial. One to decompress the file.
In Linux system operation, for some reasons, you want to create the installed package directly from
During Linux system operation, periodically deleting expired files can free up space memory and avoi
Ubuntu 12.04 is able to set the background color, but Ubuntu 12.04 can not modify t
Debian is a kind of Linux system, some people think that Debians graphical interface is not good, th
How to handle Too many open files under Linux?
Linux how to use the text processing tool awk
Linux changes the capacity of VirtualBox disk
Linux method of cutting txt large files into small files through shell script
Wget command operation example
How to sort the connector ld link under Linux
How to solve the shell script stop execution when the Linux system is scheduled?
How to use traceroute command under Linux
Linux uses instructions to release the cache step
How to modify the default timeout time of sudo in Ubuntu system?
Windows 8 Developer Preview cannot install qq solution
Windows 7 system personalized media center
Win8.1 system upgrade to Win10 (32-bit and 64-bit) specific steps
Win10 usage summary (some you don't know)
How to restore the initial password of win7 system computer
How to solve the "Other User" account when Win8.1 is turned on?
Ubuntu 12.04 background color can not be changed solution
To free up disk space, Outlook Express can compress messages. This may take a few tips to solve