Issue
I have a large tar.gz archive file having nxml
files and total size is around 5gb.
My aim is to extract files from it but, I do not have to extract all of them. I have to extract all those files whose name is greater than a threshold value.
For example:
Let us consider 1000 is our threshold value. So
path/to/file/900.nxml
will not be extracted but
path/to/file/1100.nxml
will be extracted.
So my requirement is to make a conditional extraction of files from the archive.
Thanks
Solution
- Use
tar -tf <archive>
to get a list of files in the archive. - Process the list of files to determine those you need to extract. Write the file list to a temporary file
<filelist>
, one line per file.- Looking at the tags you chose, you can use either Python or bash for this string filtering, whichever you prefer.
- Use
tar -xf <archive> -T <filelist>
to extract the files you need.
The option-T
or--files-from
reads the filenames to process from the given file.- See also the manpage for tar.
Answered By - Roland Weber
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.