Grep batch file
Jump to navigation
Jump to search
You could copy this bit into a dos batch file (sample.bat for example) and then change things around to suit the data file you're working with. First up, the command. Second the things going on will be explained.
c:\cygwin\bin\grep 249,3015,2007 "c:\data\atlas\k2-met\atlas-k-met.txt" > "c:\data\atlas\k2-met\k2-met-249-soil-2007.csv"
Program pathname: c:\cygwin\bin\grep String to look for in the data file: 249,3015,2007 Input text file: "c:\data\atlas\k2-met\atlas-k-met.txt" Dump all the lines with a string that match '249,3015,2007' in to a new file: > Output text file: "c:\data\atlas\k2-met\k2-met-249-soil-2007.csv" If you wanted to append data to an output file rather than start a fresh one use '>>' rather than '>'
So, if you are grepping data of your own rather than this sample line here the input and output files will probably change to the ones your interested in and also, the string to search for will change. Most WERC stations have a station ID in them, 3015 in this case. This simplifies the grepping operation.