Using 7z:

7z l file.7z 7z x file.7z directory/neededfile.txt

Using Tar:

tar ztvf file.tgz tar xzvf file.tgz directory/neededfile.txt

Note the “*t*” is the argument telling tar to list files, so you could do “*jtvf*” for a bz2 archive, etc…

Mario Loria is a builder of diverse infrastructure with modern workloads on both bare-metal and cloud platforms. He's traversed roles in system administration, network engineering, and DevOps. You can learn more about him here.