Sponsored Content
Full Discussion: Grep as a verb
The Lounge What is on Your Mind? Grep as a verb Post 302783551 by Ygor on Wednesday 20th of March 2013 03:42:52 PM
Old 03-20-2013
I agree that it's difficult to help people when it's difficult to grok the lingo.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

MEM=`ps v $PPID| grep -i db2 | grep -v grep| awk '{ if ( $7 ~ " " ) { print 0 } else

Hi Guys, I need to set the value of $7 to zero in case $7 is NULL. I've tried the below command but doesn't work. Any ideas. thanks guys. MEM=`ps v $PPID| grep -i db2 | grep -v grep| awk '{ if ( $7 ~ " " ) { print 0 } else { print $7}}' ` Harby. (4 Replies)
Discussion started by: hariza
4 Replies

2. UNIX for Dummies Questions & Answers

| help | unix | grep - Can I use grep to return a string with exactly n matches?

Hello, I looking to use grep to return a string with exactly n matches. I'm building off this: ls -aLl /bin | grep '^.\{9\}x' | tr -s ' ' -rwxr-xr-x 1 root root 632816 Nov 25 2008 vi -rwxr-xr-x 1 root root 632816 Nov 25 2008 view -rwxr-xr-x 1 root root 16008 May 25 2008... (7 Replies)
Discussion started by: MykC
7 Replies

3. UNIX for Dummies Questions & Answers

| help | unix | grep (GNU grep) 2.5.1 | advanced regex syntax

Hello, I'm working on unix with grep (GNU grep) 2.5.1. I'm going through some of the newer regex syntax using Regular Expression Reference - Advanced Syntax a guide. ls -aLl /bin | grep "\(x\)" Which works, just highlights 'x' where ever, when ever. I'm trying to to get (?:) to work but... (4 Replies)
Discussion started by: MykC
4 Replies

4. Shell Programming and Scripting

grep for certain files using a file as input to grep and then move

Hi All, I need to grep few files which has words like the below in the file name , which i want to put it in a file and and grep for the files which contain these names and move it to a new directory , full file name -C20091210.1000-20091210.1100_SMGBSC3:1000... (2 Replies)
Discussion started by: anita07
2 Replies

5. UNIX for Dummies Questions & Answers

Advanced grep'in... grep for data next to static element.

I have a directory I need to grep which consists of numbered sub directories. The sub directory names change daily. A file resides in this main directory that shows which sub directories are FULL backups or INCREMENTAL backups. My goal is to grep the directory for the word "full" and then... (2 Replies)
Discussion started by: SysAdm2
2 Replies

6. Shell Programming and Scripting

AWK/GREP: grep only lines starting with integer

I have an input file 12.4 1.72849432773174e+01 -7.74784188610632e+01 12.5 9.59432114416327e-01 -7.87018212757537e+01 15.6 5.20139995965960e-01 -5.61612429666624e+01 29.3 3.76696387248366e+00 -7.42896194101892e+01 32.1 1.86899877018077e+01 -7.56508762501408e+01 35 6.98857157014640e+00... (2 Replies)
Discussion started by: chrisjorg
2 Replies

7. UNIX for Dummies Questions & Answers

Bash - CLI - grep - Passing result to grep through pipe

Hello. I want to get all modules which are loaded and which name are exactly 2 characters long and not more than 2 characters and begin with "nv" lsmod | (e)grep '^nv???????????? I want to get all modules which are loaded and which name begin with "nv" and are 2 to 7 characters long ... (1 Reply)
Discussion started by: jcdole
1 Replies

8. Shell Programming and Scripting

Diff between grep .* file name and grep '.*' filename

Hi, Can anyone let me know what is difference between grep .* foo.c grep '.*' foo.c I am not able to understand what is exact difference. Thanks in advance (2 Replies)
Discussion started by: SasDutta
2 Replies

9. UNIX for Dummies Questions & Answers

Piping grep into awk, read the next line using grep

Hi, I have a number of files containing the information below. """"" Fundallinfo 6.3950 14.9715 14.0482 """"" I would like to grep for Fundallinfo and use it to read the next line? I ideally would like to read the three numbers that follow in the next line and... (2 Replies)
Discussion started by: Paul Moghadam
2 Replies

10. Shell Programming and Scripting

Inconsistent `ps -eaf -o args | grep -i sfs_pcard_load_file.ksh | grep -v grep | wc -l`

i have this line of code that looks for the same file if it is currently running and returns the count. `ps -eaf -o args | grep -i sfs_pcard_load_file.ksh | grep -v grep | wc -l` basically it is assigned to a variable ISRUNNING=`ps -eaf -o args | grep -i sfs_pcard_load_file.ksh |... (6 Replies)
Discussion started by: wtolentino
6 Replies
GROK(1) 																   GROK(1)

NAME
grok - parse logs, handle events, and make your unstructured text structured. SYNOPSIS
grok [-d] -f configfile DESCRIPTION
Grok is software that allows you to easily parse logs and other files. With grok, you can turn unstructured log and event data into structured data. The grok program is a great tool for parsing log data and program output. You can match any number of complex patterns on any number of inputs (processes and files) and have custom reactions. OPTIONS
-d or --daemon Daemonize after parsing the config file. Implemented with daemon(3). The default is to stay in foreground. -f configfile Specify a grok config file to use. CONFIGURATION
You can call the config file anything you want. A full example config follows below, with documentation on options and defaults. # --- Begin sample grok config # This is a comment. :) # # enable or disable debugging. Debug is set false by default. # the 'debug' setting is valid at every level. # debug values are copied down-scope unless overridden. debug: true # you can define multiple program blocks in a config file. # a program is just a collection of inputs (files, execs) and # matches (patterns and reactions), program { debug: false # file with no block. settings block is optional file "/var/log/messages" # file with a block file "/var/log/secure" { # follow means to follow a file like 'tail -F' but starts # reading at the beginning of the file. A file is followed # through truncation, log rotation, and append. follow: true } # execute a command, settings block is optional exec "netstat -rn" # exec with a block exec "ping -c 1 www.google.com" { # automatically rerun the exec if it exits, as soon as it exits. # default is false restart-on-exit: false # minimum amount of time from one start to the next start, if we # are restarting. Default is no minimum minimum-restart-interval: 5 # run every N seconds, but only if the process has exited. # default is not to rerun at all. run-interval: 60 # default is to read process output only from stdout. # set this to true to also read from stderr. read-stderr: false } # You can have multiple match {} blocks in your config. # They are applied, in order, against every line of input that # comes from your exec and file instances in this program block. match { # match a pattern. This can be any regexp and can include %{foo} # grok patterns pattern: "some pattern to match" # You can have multiple patterns here, any are valid for matching. pattern: "another pattern to match" # the default reaction is "%{@LINE}" which is the full line # matched. the reaction can be a special value of 'none' which # means no reaction occurs, or it can be any string. The # reaction is emitted to the shell if it is not none. reaction: "%{@LINE}" # the default shell is 'stdout' which means reactions are # printed directly to standard output. Setting the shell to a # command string will run that command and pipe reaction data to # it. #shell: stdout shell: "/bin/sh" # flush after every write to the shell. # The default is not to flush. flush: true # break-if-match means do not attempt any further matches on # this line. the default is false. break-if-match: true } } # -- End config PATTERN FILES
Pattern files contain lists of names and patterns for loading into grok. Patterns are newline-delimited and have this syntax: patternname expression Any whitespace between the patternname and expression are ignored. patternname This is the name of your pattern which, when loaded, can be referenced in patterns as %{patternname} expression The expression here is, verbatim, available as a regular expression. You do not need to worry about how to escape things. PATTERN EXAMPLES DIGITS d+ HELLOWORLD hello world REGULAR EXPRESSIONS
The expression engine underneath grok is PCRE. Any syntax in PCRE is valid in grok. REACTIONS
Reactions can reference named patterns from the match. You can also access a few other special values, including: %{@LINE} The line matched. %{@MATCH} The substring matched %{@START} The starting position of the match from the beginning of the string. %{@END} The ending position of the match. %{@LENGTH} The length of the match %{@JSON} The full set of patterns captured, encoded as a json dictionary as a structure of { pattern: [ array of captures ] }. We use an array becuase you can use the same named pattern multiple times in a match. %{@JSON_COMPLEX} Similar to the above, but includes start and end position for every named pattern. That structure is: { "grok": [ { "@LINE": { "start": ..., "end": ..., "value": ... } }, { "@MATCH": { "start": ..., "end": ..., "value": ... } }, { "patternname": { "start": startpos, "end": endpos, "value": "string" } }, { "patternname2": { "start": startpos, "end": endpos, "value": "string" } }, ... ] } REACTION FILTERS Reaction filters allow you to mutate the captured data. The following filters are available: An example of using a filter in a reaction is like this: reaction: "echo Matched: %{@MATCH|shellescape}" shellescape Escapes all characters necessary to make the string safe in non-quoted a shell argument shelldqescape Escapes characters necessary to be safe within doublequotes in a shell. jsonencode Makes the string safe to represent in a json string (escapes according to json.org recommendations) SEE ALSO
pcre(3), pcresyntax(3), Sample grok configs are available in in the grok samples/ directory. Project site: <http://semicomplete.googlecode.com/wiki/Grok> Google Code: <http://semicomplete.googlecode.com/> Issue/Bug Tracker: <http://code.google.com/p/semicomplete/issues/list> CONTACT
Please send questions to grok-users@googlegroups.com. File bugs and feature requests at the following URL: Issue/Bug Tracker: <http://code.google.com/p/semicomplete/issues/list> HISTORY
grok was originally in perl, then rewritten in C++ and Xpressive (regex), then rewritten in C and PCRE. AUTHOR
grok was written by Jordan Sissel. 2009-12-25 GROK(1)
All times are GMT -4. The time now is 05:58 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy