I think we're using different zip programs then. From the man zip
page on my system:
-r Travel the directory structure recursively; for example:
zip -r foo foo
In this case, all the files and directories in foo are saved in a zip archive named foo.zip,
including files with names starting with ".", since the recursion does not use the shell's
file-name substitution mechanism. If you wish to include only a specific subset of the files
in directory foo and its subdirectories, use the -i option to specify the pattern of files to
be included. You should not use -r with the name ".*", since that matches ".." which will
attempt to zip up the parent directory (probably not what was intended).
-R Travel the directory structure recursively starting at the current directory; for example:
zip -R foo '*.c'
In this case, all the files matching *.c in the tree starting at the current directory are
stored into a zip archive named foo.zip. Note for PKZIP users: the equivalent command is
pkzip -rP foo *.c
Actually, thinking about this some more, it's a more complicated problem that I originally thought. With the unzip -p archive.war WEB-INF/web.xml
you're extracting to stdout so that sed -e 's/ConfigFileLocation/helloworld/g'
can modify a stream. What you want to do next is replace the contents of the file WEB-INF/web.xml in the archive with that stream. But you have no file, you have a stream with no file name.
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.