Extract just a file from tar archive

Hi,
To extract just one file from tar archive
I ran:

$ gunzip -c 28948407.tar.gz | tar xvf -    
28948407/fnd/html/mainMenuTree.js 
28948407/fnd/html/mainMenuTree.js, 50562 bytes, 99 media blocks.

But it has extracted all archive:

$ ls -l

total 81864

drwxr-xr-x    3 dd dba             256 Feb 09 11:38 28948407
-rw-r--r--    1 dd dba        41904956 Feb 08 18:45 28948407.tar.gz

What is wrong?
Thanks

try

tar xzf 28948407.tar.gz 28948407/fnd/html/mainMenuTree.js

Thanks. I ran your suggestion, but:

Usage: tar -{c|r|t|u|x} [ -BdDEFhilmopRUsvwZ ] [ -Number ] [ -f TarFil e ]
           [ -b Blocks ] [ -S [ Feet ] | [ Feet@Density ] | [ Blocksb ] ]
           [ -L InputList ] [-X ExcludeFile] [ -N Blocks ] [ -C Directory ] File ...
Usage: tar {c|r|t|u|x} [ bBdDEfFhilLXmNopRsSUvwZ[0-9] ] ]
           [ Blocks ] [ TarFile ] [ InputList ] [ ExcludeFile ]
           [ [ Feet ] | [ Feet@Density ] | [ Blocksb ] ] [-C Directory ] File ...

which tar version and os are you running ?

I tested on linux mint 20.x and mac Darwin

tar --version
tar (GNU tar) 1.35
Copyright (C) 2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by John Gilmore and Jay Fenlason.


ls -al cuc.tar.gz
-rw-r--r--  1 munke  staff  9324284  9 Feb 10:56 cuc.tar.gz

tar xzf cuc.tar.gz testdir/p.sh

ls -al testdir/
total 8
drwxr-xr-x  3 munke  staff   96  9 Feb 11:23 .
drwxr-xr-x  6 munke  staff  192  9 Feb 11:26 ..
-rwxr-xr-x  1 munke  staff   79 14 Mar  2023 p.sh

apologies, i've just noticed you've marked your post as AIX ...

i don't have AIX so can't test , sry

but this should work :thinking:

gunzip -c yourarchive | tar xvf - filepath
3 Likes

We are on UNIX AIX .
I ran (as you suggested):
gunzip -c 28948407.tar.gz | tar xvf - 28948407/fnd/html/mainMenuTree.js

And it worked.
Regards.

Thank you it worked.
Regards.

np @big123456 , glad the team could be of assistance - tell all your friends/colleagues about the forum - real people given real help :+1:

rgds

2 Likes

sur, I will talk to them.
Regards.

2 Likes

Aha, the successor to AI is FABI (Flesh and Blood Intelligence) !

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.