Search workflow name in the session log file using the linux command

Viewed 68

I have a session log file generated by informatica powercenter, I need to search and print the workflow name with the file name ..I am using the below command, but it is hardcoded .. what could the possible generic command.

grep -e "workflow: \[wfk_load_oltp_stg_data\]" -o -H filename.log

note : here the text "wfk" is common in all the logs file .. any help how I write the regx t pickup the workflow name

1 Answers

Use

grep -Po 'workflow:\s*\[\Kwfk[^][]*(?=])' filename.log

See proof

Explanation

--------------------------------------------------------------------------------
  workflow:                'workflow:'
--------------------------------------------------------------------------------
  \s*                      whitespace (\n, \r, \t, \f, and " ") (0 or
                           more times (matching the most amount
                           possible))
--------------------------------------------------------------------------------
  \[                       '['
--------------------------------------------------------------------------------
  \K                       match reset operator
--------------------------------------------------------------------------------
  wfk                      'wfk'
--------------------------------------------------------------------------------
  [^][]*                   any character except: ']', '[' (0 or more
                           times (matching the most amount possible))
--------------------------------------------------------------------------------
  (?=                      look ahead to see if there is:
--------------------------------------------------------------------------------
    ]                        ']'
--------------------------------------------------------------------------------
  )                        end of look-ahead
Related