I'm trying to use ncrename to reset the _FillValue of a variable to a negative value, but the negative sign on the value I use at the command line is confusing to ncrename, it always sees it as the start of a new option argument, so I probably need to do something to escape the negative sign so it is not misrecognized as the start of a new command line option. For example I'm trying the below:
ncrename -a _FillValue, precip, o, f, -9999.9 in.nc out.nc
The above command results in this error message: "ncrename: invalid option -- '9'". I get this error message when escaping the -9999.9 with a backslash, single quotes, and double quotes. Can someone clue me in on what I need to do to use a negative value on the command line for NCO commands?
Thanks in advance for any suggestions.
the options are fine but the operator for this is ncatted not ncrename.
is your coffee undercaffeinated?
I get the same result when I use the correct NCO operator for this task:
$ ncatted -a _FillValue, precip, o, f, -9999.9 in.nc out.nc
ncatted: invalid option -- '9'
So back to the original question -- how does one escape a negative value so it doesn't confuse NCO into thinking that it's instead an invalid command line option?
It turns out that the error is having spaces in my -a clause, apparently whitespace is used to delimit options and arguments. Without the space separators the negative value passes through without an issue.