Because Linux tar commands do not support batch decompression, many netizens have compiled a lot of shell commands that support batch decompression and collected them for your sharing.
First:
For tar in * .tar.gz; do tar xvf $ tar; donefor tar in * .tar.bz2; do tar xvf $ tar; done
Type 2: Decompress all tar.gz files under a folder with a tarcommand
Ls * .tar.gz | xargs-N1 tar xzvf
I personally think this is the most convenient.
Third:
Find-maxdepth 1-name "*. bz2" | xargs-I tar xvjf {}
This command can decompress all bz2 files in the current directory. maxdepth indicates the search depth, and 1 indicates that only the current directory is searched.
Fourth:
For I in $ (LS *. Tar); do tar xvf $ I; done
Exclude specified directory:
Tar zcvf linuxany. tgz -- exclude = '*/log/*' linuxany/
Exclude specified files:
Tar zcvf linuxany. tgz -- exclude = '*/*. log *' linuxany/
Problem:
I want to decompress the tar file in batches and use tar -Xvf * An error occurs in. Tar and the system prompts "not ". Found In Archive ". There are many solutions, such as writing a script. Why does tar not support this wildcard syntax? Is there a special reason? I tried gzip to support gzip. -D * .Tar.gz.
Answer:
Wildcard is a shell Solution
For example
Tar -Xvf *. Tar
When tar is actually executed, tar receives
Tar -Xvf A.tar B .tar C.tar ...
If the current directory does not contain tar, tar receives the '*. Tar' parameter.
Different from win, all characters in Linux can be Composition File name, that is, the directory does not exist *. Tar file
To prevent * .Taris interpreted as a.tar by shell. B .tar C.tar...
It can be enclosed in single quotes.
when you use tar to unbind an archive, the syntax is
tar -xvf
.
is one or more member files in myfiles.tar. If there are multiple wildcard characters, you can use wildcard characters.
don't worry about me first. I know, you know. However, your problem is that you used
tar -xvf *. tar
As mentioned above, tar receives
tar -xvf a.tar B .tar c.tar ...
here, you can extract B .tar from a.tar. c.tar ...