Adsense Leaderboard Ad


Extract a single file from a TAR archive

It is possible to extract a single file from a tarball archive using the tar command. For this example we will use my Pink Floyd mp3 collection. I used tar to archive my songs so I can move them to my new machine. Right now I only want to extract the song "Learning to Fly" for the archive. First off we will need to know the exact name of the file. We can list the files in a tar archive using the following command. tar -tvf filename.tar Here is an example: $ tar -tvf Floyd.tar
-rw-rw-r-- savona/savona 432516 2012-01-05 14:49 Echoes.mp3
-rw-rw-r-- savona/savona 837292 2012-01-05 14:49 Goodbye_Blue_Sky.mp3
-rw-rw-r-- savona/savona 748479 2012-01-05 14:49 Green_Is_The_Colour.mp3
-rw-rw-r-- savona/savona 3455103 2012-01-05 14:49 Learning_To_Fly.mp3
-rw-rw-r-- savona/savona 234426 2012-01-05 14:49 Obscured_By_Clouds.mp3
Now we can see the filename for Learning to Fly is "Learning_To_Fly.mp3". Let's extract that one song with the following command: tar xvf filename.tar file_to_extract Example: $ tar xvf Floyd.tar Learning_To_Fly.mp3
To learn more useful tar commands please see the tar man page: man tar

No comments:

Post a Comment