Couldn't find any answer for this problem, so here I am.
I'm using ncatted from NCO inside a bash script to dinamycally change some variables unit's names in a netcdf.
ncatted is called like so (note the double quotes around Celsius):
ncatted -O -a units,temp2m,o,c,"Celsius" ncfile.nc
In order to replicate the last command in my bash script:
variables=(temp2m u10)
units=(Celsius Knots)
echo " Setting up new units"
for k in ${!variables[@]};
do
ncatted -O -a units,${variables[$k]},o,c,'"'${units[$k]}'"' ncfile.nc
echo ncatted -O -a units,${variables[$k]},o,c,"'"${units[$k]}"'" ncfile.nc
# prints ncatted -O -a units,temp2m,o,c,"Celsius" file.nc
# prints ncatted -O -a units,u10,o,c,"Knots" file.nc
done
While printing the command to shell looks ok, inside the netcdf, the new attribute will always appear like this;
units: \"Celsius\"
I've tried multiple variations of single quotes, double quotes and backslashes, but I always end up with the same result.
Although its not the end of the world, its really annoying, so I was hoping to know if anyone has a good explanation for it.
Thanks