For GRIB:
On Linux you can use the grib_copy tool. This tools comes with ECMWF's ecCodes:
grib_copy grib_file_1 grib_file_2 ... output_grib_file
On Linux you can simply concatenate the GRIB files:
cat grib_file_1 grib_file_2 ... grib_file_N > output_grib_file
For NetCDF (unsupported by ECMWF)
A way to merge netcdf files is using CDO merge:
or
Another option could be NCO (NetCDF Operators) ncrcat. Be sure that the files are unpacked before merging them. Here an example of merging for ERA5 nc files:
Download the data:
Set record dimension in each file (this is the dimension to merge along):
module load nco ncks --mk_rec_dmn time ERA5_slhf_sshf_01.nc ERA5_slhf_sshf_01_time_rec.nc ncks --mk_rec_dmn time ERA5_slhf_sshf_02.nc ERA5_slhf_sshf_02_time_rec.nc
Data are still packed - need to be unpacked before merge:
ncpdq -U ERA5_slhf_sshf_01_time_rec.nc ERA5_slhf_sshf_01_time_rec_unpack.nc ncpdq -U ERA5_slhf_sshf_02_time_rec.nc ERA5_slhf_sshf_02_time_rec_unpack.nc
Then they can be merged:
ncrcat ERA5_slhf_sshf_01_time_rec_unpack.nc ERA5_slhf_sshf_02_time_rec_unpack.nc ERA5_slhf_sshf_0102_time_rec_unpack.nc