Skip to content
Advertisement

Bash: Syntax Error Near Unexpected Token `(‘ When Using Wgrib2

Good Evening All,

I’m currently having a bash syntax issue when I try to run the following command in my terminal, the

bash: syntax error near unexpected token `(‘

error message pops up after I run the below code:

/mnt/grads/bin/wgrib2 /home/aaron/grads/data/sref_prob/20140530/15Z/sref.20140530.t15z.prob.grib2 
-match ^(255|371|487|623|759|895|1031|1187|1343|1499|1655|1811|1967|2123|2279|2435|2591|2747|2903|3059|3215|3371|3527|3683|3839|3995|4151|4307):
-grib /home/aaron/grads/data/sref_prob/20140530/15Z/test.grib2

I realize that not many people on here probably have experience using wgrib2 but, this seems like a syntax error, not an issue with the program…

Advertisement

Answer

Parentheses and pipes have special meaning to the shell, you need to quote or escape them:

/mnt/grads/bin/wgrib2 /home/aaron/grads/data/sref_prob/20140530/15Z/sref.20140530.t15z.prob.grib2 
    -match '^(255|371|487|623|759|895|1031|1187|1343|1499|1655|1811|1967|2123|2279|2435|2591|2747|2903|3059|3215|3371|3527|3683|3839|3995|4151|4307):' 
    -grib /home/aaron/grads/data/sref_prob/20140530/15Z/test.grib2
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement