TAR command

Go to solution
Ankit Grover
Frequent Advisor

TAR command

Can a single file be extracted from an archived tar file?

I have got around 200 files in a single TAR file and want to extract only few of them.
Valued Contributor

Re: TAR command

just specify the filename as it appears in the tar file you want after the tar file

In this example I've created a simple tar file of the logs directory

# tar cvf k.tar logs/E*
a logs/EventLog.ltt 8 blocks
a logs/EventLog_backup_1.ltt 9 blocks
a logs/EventLog_backup_2.ltt 8 blocks
a logs/EventLog_backup_3.ltt 8 blocks
a logs/EventLog_backup_4.ltt 2 blocks
a logs/EventLog_backup_5.ltt 2 blocks
a logs/EventLog_backup_6.ltt 8 blocks
a logs/EventLog_backup_7.ltt 8 blocks
a logs/EventLog_backup_8.ltt 8 blocks
a logs/EventLog_backup_9.ltt 98 blocks

# cd logs/output

# tar xvf ../../k.tar logs/EventLog_backup_1.ltt
x logs/EventLog_backup_1.ltt, 4344 bytes, 9 tape blocks

Had I just type EventLog_backup_1.ltt, it would have failed
Respected Contributor

Re: TAR command

do a tar tvf tarfile_name

this will show what all i sthere in the tar archive
then do a tar xvf your_file
to extract one file.

Ankit Grover
Frequent Advisor

Re: TAR command

Thanks for the solution.

tar xvf
Valued Contributor

Re: TAR command

in case you've forgotten to say thanks with points, here's the thread to say thanks to those who helped :-)