Skip Navigation Links www.nws.noaa.gov 
NOAA logo - Click to go to the NOAA home page National Weather Service   NWS logo - Click to go to the NWS home page
Climate Prediction Center
 
 

 
About Us
   Our Mission
   Who We Are

Contact Us
   CPC Information
   CPC Web Team

 
HOME > Monitoring_and_Data > Oceanic and Atmospheric Data > Reanalysis: Atmospheric Data > wgrib2-Match_fs package
 

wgrib2: -match_fs, -not_fs, -if_fs, -not_if_fs

Introduction

The (-match_fs, -not_fs, -if_fs, -not_if_fs) options are similar to the (-match, -not, -if, -not_if) options except the former group uses fixed strings rather than regular expressions. Now why would you want to use the "fs" versions? Suppose you want to to search for the "2.5 mb" level.

bash-4.1$ wgrib2 -match ":2.5 mb:" junk
1:0:d=2009060500:HGT:225 mb:180 hour fcst:ENS=+19
2:46042:d=2009060500:HGT:2.5 mb:180 hour fcst:ENS=+19
What happened? The command matched the 2.5 and 225 mb level! Well the period is regular expression metacharacter and matchs any character. To only get "2.5 mb" either have to quote the period or change the regex mode.
bash-4.1$ wgrib2 -match ":2\.5 mb:" junk
2:46042:d=2009060500:HGT:2.5 mb:180 hour fcst:ENS=+19

bash-4.1$ wgrib2 -set_regex 0 -match ":2.5 mb:" junk
1:0:d=2009060500:HGT:225 mb:180 hour fcst:ENS=+19
2:46042:d=2009060500:HGT:2.5 mb:180 hour fcst:ENS=+19

bash-4.1$ wgrib2 -set_regex 1 -match ":2.5 mb:" junk
2:46042:d=2009060500:HGT:2.5 mb:180 hour fcst:ENS=+19

bash-4.1$ wgrib2 -set_regex 2 -match ":2.5 mb:" junk
2:46042:d=2009060500:HGT:2.5 mb:180 hour fcst:ENS=+19

So setting the regex mode to 1 or 2 will work. The "_fs" options uses fixed strings with no metacharacters which is the same as the regex mode set to 1.

The "_fs" options only requires standard C support rather than POSIX-2 so they are available on all wgrib2. Options using regular expressions are optional and may not be available on platforms.

See also: -if, -if_fs, -match, -match_inv, -not, -not_fs, -not_if, -not_if_fs, -set_regex.


NOAA/ National Weather Service
National Centers for Environmental Prediction
Climate Prediction Center
5830 University Research Court
College Park, Maryland 20740
Climate Prediction Center Web Team
Page last modified: March 15, 2016
Disclaimer Privacy Policy