Question: Given a compressed archive file such as `application.tar.gz` which has a folder `application/x/y/z.jar` among others, I'd like to be able to take my most recent version of `z.jar` and update/refresh the archive with it.

Is there a way to do this other than something like the following?

```
tar -xzf application.tar.gz
cp ~/myupdatedfolder/z.jar application/x/y
tar -czf application application.tar.gz

```

I understand the `-u` switch in tar may be of use to avoid having to untar the whole thing, but I'm unsure how to use it exactly.

Answer: 
Well, I found the answer.

You can't use `tar -u` with a zipped archive. So the solution I used was the following. Note that I moved the `z.jar` file to a folder I created in the current directory called `application/x/y` for this purpose.

```
gzip -d application.tar.gz
tar -uf application.tar application/x/y/z.jar
gzip application.tar

```

When I did a `tar -tf application.tar` (after the update, before the gzip) it showed up properly.
If the file you want to update is text file. Then you can use `vim` editor directly to open the tarball that contains the file and open it, just like open folder using vim editor. Then modify the file and save it and quit.

However, if the file is a binary. I have no idea about the solution.