How to create a tar + gzip from a listing of file names.
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix administration > How to create a tar + gzip from a listing of file names.




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    How to create a tar + gzip from a listing of file names.  
Daryl Rose


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-25-07 12:19 AM

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






[ Post a follow-up to this message ]



    Re: How to create a tar + gzip from a listing of file names.  
Bo Yang


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-25-07 12:19 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)





[ Post a follow-up to this message ]



    Re: How to create a tar + gzip from a listing of file names.  
Doug Freyburger


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-25-07 06:19 PM

"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.






[ Post a follow-up to this message ]



    Re: How to create a tar + gzip from a listing of file names.  
Stephane CHAZELAS


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-26-07 12:25 AM

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





[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 12:49 PM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register