Find and replace in a gz file

Is there a way to do a find and replace in a .gz file in a single script ?

I can always unzip, find and replace and then zip it again but would hate to do this everytime.

Thanks !
Vivek

Yes.

Put the commands into a script, e.g.:

## NAME: srgz
## USAGE: srgz FILE SEARCH REPLACE
file=$1
find=$2
replace=$3
gunzip "$file"
sed "s/$find/$replace/" "${file%.gz}" |
 gzip -c > "${file%.gz}.gz}"

(This is untested, and does not deal with slashes in the find and replace strings.)