I'm not totally sure what you want to do in the end, so maybe I'm way off here. If so, sorry.
Given your snippet,
Quote:
...EXIT 16 FI JOBNAME=DA331Z_LD_CCC_BSE_TBLS_M PROCNAME1=VEH_INC_PART_UPDTBASE_M.SQL $ORACLE_SCRIPT_PROC/SQLSCRIPT_BATCH INC_PART2_UPDTBASE_M.SQL
SCRERROR=$? IF [ $SCRERROR -NE 0 ] THEN ECHO "ERROR: " INC_PART2_UPDTBASE_M.SQL" FAILED ...
Assume that is in a file called "bla.txt".
This:
Quote:
grep -ioP '(?<= )[[:alnum:]_]+=[[:alnum:]_]+\.SQL ' bla.txt | awk -F= '{print $1,$2}'
Will output:
PROCNAME1 VEH_INC_PART_UPDTBASE_M.SQL
If you had more scripts in it it would pick up each one (I think), unless the var/proc pair was broken up by a carriage return.
You can probably tune it quite a bit for your situation, whatever that is.
Brief explanation:
-i case insensitive match
-o just print the matched string, not the whole line like usual
-P use Perl regex's (for the lookbehind)
(<?<= ) lookbehind matches the space before your "proc" name but keeps it out of the -o print
[[:alnum:]_]+=[[:alnum:]_]+\.SQL match one or more alphanumeric or _ characters followed by "=" followed by one or more alphanumerics or _ followed by ".sql"
Then pipe it to awk to print the first and second fields delimited by "=".
You could do other things too like add a -r to the grep to search a whole directory structure recursively, or pipe everything to "sort -u" to eliminate duplicate results, even "sort | uniq -c | sort -n" to get numeric values for how often the same proc/var name pairs occur.
---------- Post updated Jan 20th, 2011 at 03:58 PM ---------- Previous update was Jan 19th, 2011 at 10:58 PM ----------
I just realized I should have posted that reply to owenian rather than methyl to be in the proper place in this thread....sorry...it's my first post @ unix.com.