Write NetCDF file to text:
ncdump <file>.nc > <file>.cdl
Write a .cdl file to be a NetCDF file with:
ncgen -k nc4 <file>.cdl -o <file>.nc
These can be chained together or combined with other command line tools.