Have you looked at ncks in NCO
(http://nco.sourceforge.net/nco.html#ncks-netCDF-Kitchen-Sink). Some of the
examples appear to be doing just what you say.
-Roy
On May 18, 2012, at 2:25 PM, Tom Roche wrote:
>
> Is there an easy and quick way to *get* the value of an attribute
> (whether global or variable) from a (bash) shell commandline or
> script? AFAICS
>
> * NCO's `ncatted` will allow one to *set* an attribute value, but is
> write-only.
>
> * R package=ncdf4 will allow one to get an attribute value, but
> requires loading R, plus writing a fair bit of code.
>
> Am I missing something? Currently, unless I need to run R for other
> reasons, I'm writing bash like
>
> if [[ "$(ncdump -h ${F} | fgrep -e ${OUTPUT_VAR_NAME}:units)" =~
> "${OUTPUT_VAR_UNITS}" ]] ; then
> echo -e 'output!'
> fi
>
> which is not as robust as I'd like.
>
> TIA, Tom Roche <Tom_Roche@xxxxxxxxx>
>
> _______________________________________________
> netcdfgroup mailing list
> netcdfgroup@xxxxxxxxxxxxxxxx
> For list information or to unsubscribe, visit:
> http://www.unidata.ucar.edu/mailing_lists/
**********************
"The contents of this message do not reflect any position of the U.S.
Government or NOAA."
**********************
Roy Mendelssohn
Supervisory Operations Research Analyst
NOAA/NMFS
Environmental Research Division
Southwest Fisheries Science Center
1352 Lighthouse Avenue
Pacific Grove, CA 93950-2097
e-mail: Roy.Mendelssohn@xxxxxxxx (Note new e-mail address)
voice: (831)-648-9029
fax: (831)-648-8440
www: http://www.pfeg.noaa.gov/
"Old age and treachery will overcome youth and skill."
"From those who have been given much, much will be expected"
"the arc of the moral universe is long, but it bends toward justice" -MLK Jr.