|
|
How to create a tar + gzip from a listing of file names.
I have a file with about a dozen file names in it. I want to create a
tar/gzip of those files.
Currently I have it written this way:
CNT=0
while read line
do
if [ $CNT -eq 0 ]
then
tar cvf BKUPTST_$DATE.tar $line
CNT=1
else
tar rvf BKUPTST_$DATE.tar $line
fi
done < $APP_PATH/$APP/$DB/archive.lst
gzip BKUPTST_$DATE.tar
This works, but I would like to find a better way to do this. BTW, this
is Unix tar, not a GNU tar. If it were GNU, then I know there are
options to read in from a file and compress all in one step.
Anyone have any idea's?
Thank you.
Daryl
|
|
0
|
|
|
|
Reply
|
jzlvr1 (5)
|
1/24/2007 9:27:46 PM |
|
Daryl Rose :
> I have a file with about a dozen file names in it. I want to create a
> tar/gzip of those files.
>
> Currently I have it written this way:
>
> CNT=0
> while read line
> do
> if [ $CNT -eq 0 ]
> then
> tar cvf BKUPTST_$DATE.tar $line
> CNT=1
> else
> tar rvf BKUPTST_$DATE.tar $line
> fi
> done < $APP_PATH/$APP/$DB/archive.lst
>
> gzip BKUPTST_$DATE.tar
>
> This works, but I would like to find a better way to do this. BTW, this
> is Unix tar, not a GNU tar. If it were GNU, then I know there are
> options to read in from a file and compress all in one step.
>
> Anyone have any idea's?
>
> Thank you.
> Daryl
>
Does the following code works for you ?
tar cvf BKUPTST_$DATE.tar $(sed 's/\n/ /g' < archive.lst)
|
|
0
|
|
|
|
Reply
|
Bo
|
1/25/2007 10:56:51 AM
|
|
"Daryl Rose" <jzl...@yahoo.com> wrote:
>
> I have a file with about a dozen file names in it. I want to create a
> tar/gzip of those files.
tar -cf - -I file | gzip > tarball.tgz
file should contain nothing but the names, one to a line, preferably
without a leading /.
If your tar doesn't have a -I option, consider:
tar cf - ` cat file ` | ...
which will work as long as the number/character-count of the files
does not blow the shell buffer.
|
|
0
|
|
|
|
Reply
|
Doug
|
1/25/2007 6:46:48 PM
|
|
2007-01-25, 18:56(+08), Bo Yang:
[...]
> Does the following code works for you ?
>
> tar cvf BKUPTST_$DATE.tar $(sed 's/\n/ /g' < archive.lst)
$(....) splits upon space, tabs and newlines by default and also
expands the wildcards. So you don't need to convert newlines to
spaces. You should rather make sure $(...) only splits on
newlines, and doesn't expand the wildcards:
IFS='
'
set -f
--
St�phane
|
|
0
|
|
|
|
Reply
|
Stephane
|
1/25/2007 9:43:33 PM
|
|
|
3 Replies
385 Views
(page loaded in 0.069 seconds)
|
|
|
|
|
|
|
|
|