![]() ![]() ![]() tar format, you'd be doing tar's job in a program / shell script of your own.Īlternatively, honestly, since a tar needs to be read sequentially anyways, and storage is usually cheap, just extract everything, noting the extracted files on the way, and delete the "wrong" ones later.Įven more alternatively, might be worth trying whether 7z extracting a tar file also aborts when a pattern doesn't match.Īnd, finally: Every proper programming language probably has a tar-consuming library. ![]() In short, aside from reading the (pretty stupid). Files available from the NCBI anonymous FTP site have been compressed using the gzip program (and have the extension. f, -fileARCHIVE Use archive file or device ARCHIVE. When given, they specify the names of the members to list. You should then also handle the other TAR_** environment variables set to handle file/directory types, owners, modes and dates correctly. 11 Answers Sorted by: 425 Run the below command in the terminal to see the contents of a tar.gz file without extracting it: tar -tf -t, -list List the contents of an archive. tar will set the TAR_REALNAME environment variable, which your program can use to select whether the data piped in will be written to a file of an appropriate name, or just ignored. So, that would leave you (at least in GNU tar) with the option to execute a command on each executed file, using the -to-command= option. 11 Answers Sorted by: 425 Run the below command in the terminal to see the contents of a tar.gz file without extracting it: tar -tf -t, -list List the contents of an archive. You will not like what happens when file names contain line breaks, which is perfectly legal. If the tar archive is small enough or not read from a medium that's expensive to rewind ( actual tape archives), you could list_of_matching_files=$(tar -tf | grep '(aaa|bbb|ccc)') to compile a list of files. The GNU and BSD tar commands don't support that as far as I know, but: this unzips it in your current working directory. To compress: zip squash.zip file1 file2 file3. See for where improving the API in this regard is currently being discussed. If you are referring specifically to the Zip file format, you can simply use the zip and unzip commands. Add the p flag to the substitutions so get a report of what substitutions are being made.īeware that with the pax implementation from MirBSD as found on Debian/Ubuntu at least, I find that if there are archive members that are symlinks, they are discarded if the symlink target doesn't match the patterns (even if their path does). To see what would be extracted, you can remove the -r. The idea being that for all archive members that contain either aaa, bbb or ccc in their path, we replace those with the same, so a no-op but that results in the next substitutions to be skipped when there's a match and in particular the s.*:: which has the effect of discarding the archive member. One option could be to use pax, the standard command to extract tar archives and use the -'s/regexp/replacement/ option to remove the members we don't want from the selection: < gunzip | ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |