Operating System - HP-UX
1834355 Members
2025 Online
110066 Solutions
New Discussion

Re: Need some tar commands

 
SOLVED
Go to solution
Debbie Fleith
Regular Advisor

Need some tar commands

I need a few simple tar commands that I can't seem to find easily.

1. How would I tar up a file to a file (allfiles.tar) containing all the files within a filename (allfiles.lst) that contains a list of the path/files that I want allfiles.tar to contain?

2. How would I extract one file from a tar format tape?

4 REPLIES 4
Jeff_Traigle
Honored Contributor
Solution

Re: Need some tar commands

1. tar cvf allfiles.tar $(cat allfiles.lst)

Only problem might be if there are a ton of files and the command ends up being too long.

2. tar xvf allfiles.tar path_of_file

path_of_file is the path as it exists in the archive. (i.e. if it's relative path in the archive, you must specify it as relative path in the tar command.)
--
Jeff Traigle
TwoProc
Honored Contributor

Re: Need some tar commands

1.
tar cvf allfiles.tar `cat allfiles.lst`

2.
tar xvf /dev/rmt/0m /mydir/myfile.txt

above assumes /dev/rmt/0m is your tape dirve and /mydir/myfile.txt is the file you want to restore.
We are the people our parents warned us about --Jimmy Buffett
Jeff_Traigle
Honored Contributor

Re: Need some tar commands

Oops. Missed the tape part on your second question. John got that one. Note that tar assumes /dev/rmt/0m if the f option is not specified.
--
Jeff Traigle
Bharat Katkar
Honored Contributor

Re: Need some tar commands

1. # cat allfiles.lst | xargs < tar cvf allfiles.tar

2. # tar xvf

Regards,

You need to know a lot to actually know how little you know