1843962 Members
2011 Online
110226 Solutions
New Discussion

Re: tar cf -C

 
SOLVED
Go to solution
Vanquish
Occasional Advisor

tar cf -C

Hi Everyone
I have to tar couple of files but the directory structure in my box is different from where the tar file is extracted.
I did write a script since there are numerous files whati did is
#!/usr/bin/sh
SCRIPTDIR=/home
HOME=$SCRIPTDIR/Patch
RIPFILE=$SCRIPTDIR/Patch/lists/rip_files.txt
FRSTFL=1
cd $SCRIPTDIR/
for FILE in `cat $RIPFILE`
do
if [ $FRSTFL = "1" ]
then /usr/local/bin/tar cf $HOME/TESTPATCH.tar $FILE -C $HOME?????????
FRSTFL=0
else /usr/local/bin/tar uf $HOME/TESTPATCH.tar $FILE
fi
done

The format in my box is /home/ABC/temp/123/...
i want to remove temp it should be like
ABC/123/...
Thanks
3 REPLIES 3
Sundar_7
Honored Contributor

Re: tar cf -C

I tried my best to understand your question but guess it is not good enough :-)

Source: /home/ABC/temp/123
Destionation: /home/ABC/123

Is that what u r looking for ?

Try this

# tar -cvf 1.tar /home/ABC/temp/123/*

Destination

# pax -rf 1.tar -s '|temp||'

Learn What to do ,How to do and more importantly When to do ?
Vanquish
Occasional Advisor

Re: tar cf -C

Thanks for Reply
Since there are to many files to tar i have to read them from a file.
Therefore the destination where it has to be untar that does not has temp folder the
directory structure is different.

home/abc/temp/123/...

home/ABC/123/...

there is no temp folder in the destination directory structure.
Thanks
Michael D'Aulerio
Regular Advisor
Solution

Re: tar cf -C

If you have that many files to tar, can you just tar the whole directory. That makes it a lot easier. On the source machine:

cd /home/abc/temp/123
tar cf TESTPATCH.tar .

On destination:
cd /home/abc/123
tar xf TESTPATCH.tar

You can also use xargs to make the tar file:
cd /home/abc/temp/123
cat $RIPFILE | xargs tar cf TESTPATCH.tar
Email: michael.n.daulerio@lmco.com