Extract my-file.txt
from the files.tar
archive.
You can use this short tar command.
tar -xvf files.tar files/my-file.txt
Or this more verbose tar command.
tar --extract --verbose --file files.tar files/my-file.txt
Ensure you provide the full path to the file you need to extract. Ie. directory/directory/directory/my-file.txt
. Tar won't know which file to extract if you don't.
Note: The required directories will be extracted also.
-x
or --extract
tells tar to extract an existing archivev
or --verbose
tells tar to produce verbose outputf
or --file
tells tar that the next parameter will be the tar file to create, extract, append to, list, etc.