replacing a file in a zip from command line
I'm using zip and unzip to set parameters on the fly in some java war files.
I can use the following:
unzip -p archive.war WEB-INF/web.xml | sed -e 's/ConfigFileLocation/helloworld/g' | zip -r archive.war -
The unzip works 100%
The sed works 100%
The zip adds the edit to the file as a file called '-'
Using anything but '-' as the final parameter to zip gives the following:
zip error: Nothing to do!
P.S. A war file is a correctly formatted zip file, by the way. :-)
I don't think you need the -r flag. It means recursive and you're not recursing a directory structure. The man page gives the example:
Thanks for that - I thought the same; but -r means 'replace' (-R is resursive). Without the -r I get the same error:
zip error: Nothing to do! (archive.war)
The only time I don't seem to get this error is wth 'zip -r archive.war -', which, as I say creates a file in the image called '-'
Any other ideas? This is really bugging me now- I can't believe unzip can work on the fly but zip cannot...
I think we're using different zip programs then. From the man zip page on my system:
I haven't tried it again, but it may be that you have to create the file (and the path to it?) and then replace the file in the archive with that. Having the path preserved complicates it slightly more than a flat archive would - but you can't get away from that structure with the .war file.
Sorry I couldn't solve it.
|All times are GMT -5. The time now is 12:11 AM.|