Reputation: 67
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
Upvotes: 1
Views: 192
Reputation: 64
You can also use --wildcards
option of tar.
For example in the case when your threshold is 1000 you can use tar -xf tar.gz --wildcards path/to/files/????*.nxml
. The ?
will match one character and using *
will match any number of character. This pattern will look for any file name with 4 or more characters.
Hope this helps.
Upvotes: 1
Reputation: 3655
tar -tf <archive>
to get a list of files in the archive.<filelist>
, one line per file.
tar -xf <archive> -T <filelist>
to extract the files you need.-T
or --files-from
reads the filenames to process from the given file.
Upvotes: 1