I have a tar archive foo.tar.gz, inside of which a directory containing another directory contains a file: folder_1/folder_2/file.txt.
I want to untar file.txt without extracting folder_1/folder_2/.
tar -xvf foo.tar.gz folder_1/folder_2/file.txt
I get file.txt inside the subdirectories that contained it inside the tar archive (folder_1/folder_2/file.txt).
Is there a way of getting only file.txt and nothing else in a single command, avoiding extracting everything?