cdo has the capability to read and write grib files. However, some precompiled binaries (from some Linux program repositories) neglect this feature sometimes.
Depending on the wanted average, you compute, for instance:
cdo timmean input.grb output.grb (all time mean)
cdo yearmean input.grb output.grb (year mean)
cdo monean input.grb output.grb (monthly mean)
-- please inspect the section "Statistical values " in the documentation
Since grib files hold meta data via code tables, you may name one of the available code tables or provide you own one via the "-t" flag. This is not necessary, but I consider it as a good practice if you want to share files.