my-file.txt from the
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.
--extracttells tar to extract an existing archive
--verbosetells tar to produce verbose output
--filetells tar that the next parameter will be the tar file to create, extract, append to, list, etc.