Sponsored Content
Special Forums UNIX Desktop Questions & Answers Unix Grep Conundrum - Not for Noobies Post 302489177 by grepeverything on Thursday 20th of January 2011 09:58:54 AM
Old 01-20-2011
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.

Last edited by grepeverything; 01-20-2011 at 10:58 AM..
 

8 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Samba 2.2.5 smb.conf for noobies

Is there a generic smb.conf file that should work on all systems? Right now I am running Red Hat 7.3 and also have 3XP machines and 1 2000 pro. (1 Reply)
Discussion started by: GJC
1 Replies

2. Shell Programming and Scripting

Sed pattern space/looping conundrum

Although my sed skills are gradually developing, thanks in large part to this forum, I'm having a hard time dealing with pattern space and looping, which I suspect is what I'll need a better handle on to figure out my current issue, which is converting a multi line file like this: ... (4 Replies)
Discussion started by: tiggyboo
4 Replies

3. UNIX for Dummies Questions & Answers

umask conundrum

Hi All, i was reading up on a umask question on this forum and have a question on this. the umask value on my home PC running on cygwin is 022. when i create a dir it defaults to permission 755, when i create a file it defaults to 644. Now it starts at 777 for dirs and 666 for files and... (1 Reply)
Discussion started by: Irishboy24
1 Replies

4. Shell Programming and Scripting

Conundrum - Flexible way to strip extension

Hi, First post here. I have something that may prove to be difficult. I have the following files: Example1.0.0.tar.gz Example2.tar Example3.zip Example4.0.0.0.0.0.bzip2 I need to remove the file extensions and store as a variable so they look like this: Example1.0.0 Example2... (3 Replies)
Discussion started by: Spadez
3 Replies

5. Shell Programming and Scripting

sudo scripts conundrum

hello; Got a problem running monitoring scripts using sudo ssh.. Mgmt decided to take away root sudoers access.. so most of the scripts ran as: sudo ssh $BOX ... Now I need to run them as: echo $my_pw | sudo -S -l my_user_id $BOX ... I tried this but not working.. Any wisdom/tricks... (3 Replies)
Discussion started by: delphys
3 Replies

6. Red Hat

Physical Volume Create Conundrum

I want to start by saying I already resolved my issue but I want to understand why I am seeing what I am seeing. I have a server with a RAID controller two 500GB drives and six 600GB drives. The two 500GB drives are mirrored and have the OS installed on them. The six 600GB they wanted set as... (4 Replies)
Discussion started by: scotbuff
4 Replies

7. IP Networking

iptables conundrum

Ok, if youre reading this prepare yourself.(debian based os) so im trying to do this routing with ip tables, i need to forward/SNAT traffic from 192.168.111.1 to 10.10.10.250, the 192.x.x.x ips are being shoved into a honeyd like program called inetsim so its offline, 10.10.10.125 is connected... (3 Replies)
Discussion started by: Shocco
3 Replies

8. OS X (Apple)

Help in explaining this echo conundrum.

OSX 10.12.3, default bash terminal. Consider this code and note it is calling 'sh' inside the code... #!/bin/sh echo '1\n2\n2\n3\n5' > /tmp/text hexdump -C /tmp/text /bin/echo '1\n2\n3\n4\n5' > /tmp/text hexdump -C /tmp/text Now view the interactive mode below, note the underlying shell is... (6 Replies)
Discussion started by: wisecracker
6 Replies
SQL::Statement::Term(3pm)				User Contributed Perl Documentation				 SQL::Statement::Term(3pm)

NAME
SQL::Statement::Term - base class for all terms SYNOPSIS
# create a term with an SQL::Statement object as owner my $term = SQL::Statement::Term->new( $owner ); # access the value of that term $term->value( $eval ); DESCRIPTION
SQL::Statement::Term is an abstract base class providing the interface for all terms. INHERITANCE
SQL::Statement::Term METHODS
new Instantiates new term and stores a weak reference to the owner. value Abstract method which will return the value of the term. Must be overridden by derived classes. DESTROY Destroys the term and undefines the weak reference to the owner. NAME
SQL::Statement::ConstantTerm - term for constant values SYNOPSIS
# create a term with an SQL::Statement object as owner my $term = SQL::Statement::ConstantTerm->new( $owner, 'foo' ); # access the value of that term - returns 'foo' $term->value( $eval ); DESCRIPTION
SQL::Statement::ConstantTerm implements a term which will always return the same constant value. INHERITANCE
SQL::Statement::ConstantTerm ISA SQL::Statement::Term METHODS
new Instantiates new term and stores the constant to deliver and a weak reference to the owner. value Returns the specified constant. NAME
SQL::Statement::ColumnValue - term for column values SYNOPSIS
# create a term with an SQL::Statement object as owner my $term = SQL::Statement::ColumnValue->new( $owner, 'id' ); # access the value of that term - returns the value of the column 'id' # of the currently active row in $eval $term->value( $eval ); DESCRIPTION
SQL::Statement::ColumnValue implements a term which will return the specified column of the active row. INHERITANCE
SQL::Statement::ColumnValue ISA SQL::Statement::Term METHODS
new Instantiates new term and stores the column name to deliver and a weak reference to the owner. value Returns the specified column value. AUTHOR AND COPYRIGHT
Copyright (c) 2009,2010 by Jens Rehsack: rehsackATcpan.org All rights reserved. You may distribute this module under the terms of either the GNU General Public License or the Artistic License, as specified in the Perl README file. perl v5.10.1 2011-02-01 SQL::Statement::Term(3pm)
All times are GMT -4. The time now is 08:25 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy