Simpler Navigation for Servers and Operating Systems - Please Update Your Bookmarks
Completed: a much simpler Servers and Operating Systems section of the Community. We combined many of the older boards, so you won't have to click through so many levels to get at the information you need. Check the consolidated boards here as many sub-forums are now single boards.
If you have bookmarked forums or discussion boards in Servers and Operating Systems, we suggest you check and update them as needed.
cancel
Showing results for 
Search instead for 
Did you mean: 

TAR command

SOLVED
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.
4 REPLIES
Mancboy
Valued Contributor
Solution

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
Vipulinux
Respected Contributor

Re: TAR command

Hi
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.

Cheers
Ankit Grover
Frequent Advisor

Re: TAR command

Thanks for the solution.

tar xvf
Mancboy
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 :-)

http://forums1.itrc.hp.com/service/forums/bizsupport/helptips.do?#33