Operating System - HP-UX
1819791 Members
3413 Online
109607 Solutions
New Discussion юеВ

how to tar all files ending in .dat and one file ending in .dmp?

 
SOLVED
Go to solution
denise_7
Frequent Advisor

how to tar all files ending in .dat and one file ending in .dmp?

I want to tar a whole directory of files that end in .dat and one file that ends in .dmp. How do I do set up the tar command? Also, I want to list tape and print out contents of tape. My problem is I am used to tar a whole directory.
Thanks for the help.
7 REPLIES 7
Chris Vail
Honored Contributor

Re: how to tar all files ending in .dat and one file ending in .dmp?

One of the easiest ways to do this is to put all your filenames into a text file. Then the command "tar cvf /tmp/tarfile `cat $FILE`" will create a tarball with all your files.

Also you can list all your files from the prompt: "tar cvf /tmp/tarfile *.dat FILE.dmp".

Confirm this with "tar tvf /tmp/tarfile"


Chris
Massimo Bianchi
Honored Contributor

Re: how to tar all files ending in .dat and one file ending in .dmp?

Hi,
assuming your directory is /YOURDIR andyour tape device /dev/rmt/0m

To save all the contents of your directory

tar -cvf /dev/rmt/0m /YOURDIR

To save just *.dmp and *.dat file in your dir

tar -cvf /dev/rmt/0m /YOURDIR/*.dmp /YOURDIR/*.dat

this will propmt each file to stdout.


if you want to redirect output also to an inventory file

tar -cvf /dev/rmt/0m /YOURDIR
| tee -a /tmp/inventory.log



HTH,
Massimo
Mark Greene_1
Honored Contributor
Solution

Re: how to tar all files ending in .dat and one file ending in .dmp?

If all the files you want are in the same directory:

tar cvf /tmp/newfile.dmp *.dat

To read the contents of the tape, assuming drive 0:

tar tvf /dev/rmt/0m

HTH
mark
the future will be a lot like now, only later
denise_7
Frequent Advisor

Re: how to tar all files ending in .dat and one file ending in .dmp?

I created a tar file of the files I wanted. But the files were not redirected to a log file as this command should:

tar -cvf /dev/rmt/0m /mydir | tee -a /tmp/inventory.log

I see nothing in the inventory.log. So I went ahead and did this

tar tvf /dev/rmt/0m | tee -a /tmp/inventory.log

My question: Should the inventory.log show the size increase when I to a ps -ef | grep inventory.log?

The tar tvf seems to do nothing and it is not piping the output to the inventory.log file. What is the problem here?

Thanks.
Umapathy S
Honored Contributor

Re: how to tar all files ending in .dat and one file ending in .dmp?

Mostly the problem is with the inventory.log already there. Try to rm the inventory.log and do it again.

HTH
Umapathy
Arise Awake and Stop NOT till the goal is Reached!
denise_7
Frequent Advisor

Re: how to tar all files ending in .dat and one file ending in .dmp?

I got it! Thanks guys!
V. Nyga
Honored Contributor

Re: how to tar all files ending in .dat and one file ending in .dmp?

Hi Denise,

one more tipp for working with tar:
Most times it is better to work with relative pathes than with absolute.
So ./YOURDIR is better for extracting the files later because then the directory 'YOURDIR' and the files are created relative to your current directory.

Regards
Volkmar
*** Say 'Thanks' with Kudos ***