![]() It also extracts the compressed tar.gz, tbz, tbz2, and tar.xz files. Up to you which you find easier or most useful. 1 Answer Sorted by: 3 Using the GNU tar command, you can do this: tar -xf -one-top-levelsomedir From man 1 tar: -one-top-level DIR Extract all files into DIR, or, if used without argument, into a subdirectory named by the base name of the archive (minus standard compression suffixes recognizable by -auto-compress). Linux offers the tar command to extract tar files to a specific directory. Option 2 $ tar -xzf -wildcards -no-anchored '*contract*' ![]() Then you extract what you want using: $ tar -xzf This will list the details of all files whose names contain your known part. a two line approach would be: NEWTMPDIRmktemp -d tar -C NEWTMPDIR -xvf foo. You have two options:Įither use tar and grep to list the contents of your tarball so you can find out the full path and name of any files that match the part you know, and then use tar to extract that one file now you know its exact details, or you can use two little known switches to just extract all files that match what little you do know of your file name-you don't need to know the full name or any part of its path for this option. you could do this: tar -C mktemp -d -xvf foo.tar Which extracts foo.tar into a temp directory but that is only technically correct because it doesn't tell you where the directory is. 5 Answers Sorted by: 270 This should work: mkdir prettyname & tar xf uglyname. If the directories do exist the script will still work - the mkdir will simply fail. ![]() The script below assumes that the directories do not exist and must be created. Let's assume you have a tarball called and you just know there is one file in there you want but all you can remember is that its name contains the word contract. You can specify the directory that the extract is placed in by using the tar -C option. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |