Skip to content

Instantly share code, notes, and snippets.

@baelter
Last active August 29, 2015 14:08
Show Gist options
  • Save baelter/363d93a33f9176c92669 to your computer and use it in GitHub Desktop.
Save baelter/363d93a33f9176c92669 to your computer and use it in GitHub Desktop.
Search netCDF files for keys
#!/bin/bash
path=${@: -2:1}
term=${@: -1:1}
if [[ !(-d $path) ]]; then
echo "Usage: ncfind [-f] PATH PATTERN"
exit 0
fi
execs="find . -name '*.nc' -exec grep -E -i -a -q '$term' {} \; -print "
if [[ $1 != '-f' ]]; then
execs="$execs | xargs -t -L 1 ncdump -h "
fi
echo "eval $execs"
eval $execs
exit 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment