Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Question with tar

Status
Not open for further replies.

pmcmicha

Technical User
May 25, 2000
353
I am trying to get files from one server to another server. The problem is that these files are scattered about in different directories, so currently a script is setup to copy each of these files into one directory. The problem is that this takes to long to complete. The files are pretty big and we are coping from one slice to another slice.

I would like to tar up each file based off a list like cpio can do and then remove the directory structure so that when the file is un-tar'ed it will only put that file in the current directory. Is this possible?

UNIX Platform: SCO Unixware 7.1.1 (Where files exist)
Unix Platform: Solaris 5.6 (Where files are going)

Thanks in advance.
 
something like that - pretty rough 'as is'
'tar.txt' - a file containing a list of ABSOLUTE pathnames
'tar.tar' - a resulting tar file with 'flat' file names
#!/bin/ksh

listFile='tar.txt'
targetTAR='/tmp/tar.tar'

for file in $(< ${listFile})
do
if [ -f ${targetTAR} ] ; then
cr='r';
else
cr='c';
fi;
(cd ${file%/*} ; tar -${cr}vf /tmp/dd/tar.tar ${file##*/})
done;
vlad
+---------------------------+
|#include<disclaimer.h> |
+---------------------------+
 
I haven't tried this but it might work.

tar cvf f.tar -C /dir1 -I dir1files -C /dir2 -I dir2files ...

where dir1files is a text file containing a list of files in directory /dir1, one per line with no leading or trailing spaces. Or if there are only a few files in each directory, list them instead of using -I.

CaKiwi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top