foreach v ( `ls *nc | cut -f 1 -d _ | uniq` ) foreach f ( $v*nc ) set n = `ncdump -h $f | grep long_name | cut -f 2 -d '"' | grep _ | perl -pe 's/_/ /g'` ncatted -h -a long_name,$v,m,c,"$n" $f end end
Isn't that horrible-looking? But it works. For those who don't speak shell, that means "Please go through all the NetCDF datafiles in this directory, find the 'long_name' attribute of the main variable in the metadata, and replace all the underscores in that tag with spaces. Because the modeler did it wrong."
It came to me this morning while I was waking up that it really was this easy to implement the fix, so I had to get up and write it all down while I was still in my bathrobe. It took longer to make sure I was doing it right before I ran it on the real data than it did to actually work out the details in the first place.
Go pipe! Go backticks!