Unix Grep Conundrum - Not for Noobies


 
Thread Tools Search this Thread
Special Forums UNIX Desktop Questions & Answers Unix Grep Conundrum - Not for Noobies
# 1  
Old 01-18-2011
Unix Grep Conundrum - Not for Noobies

Help,

I have been stuck on this issue for weeks.
I am a unix noobie.

I have a very long string and within that string I am trying to get proc file names
ie
PROCNAME1=SOME_FILENAME_UPDTBASE.SQL

There is a space on either side.

I can't for the life of me peel out the proc name: SOME_FILENAME_UPDTBASE.SQL

I have a file I am comparing it against to verify it is a valid script but I can't verify it as I can't peel it out with grep.

I have hacked with awk and sed but no luck.

Any help would be appreciated.

Thanks in advance
# 2  
Old 01-18-2011
I think your question is a little ambiguous...do you simply want:
Code:
awk -F= '{ print $2 }'

# 3  
Old 01-18-2011
can you show an example line?

Should be something like
Code:
cut -d" " -f6

to get the sixth field broken by a space
Code:
awk -F" " '{print $6}'

again to get the sixth field
# 4  
Old 01-18-2011
sorry guys,

I forgot to mention:

the problem:
PROCNAME1=VEH_INC_PART_UPDTBASE_M.SQL

variable name: PROCNAME1
proc name: VEH_INC_PART_UPDTBASE_M.SQL

I don't know either the varibale name or proc name I am searching for nor it's location in the file.

My job searches hundreds of scripts pulling out the variable names then compares them with a list of procs in a file.

I can get most of them as they have space between calling proc and name.sql

But when there is no space before the script name and the variable name can be anything I have nothing concrete to search for.

Thank you for you time
# 5  
Old 01-18-2011
please paste a section of the file

Please put a piece of your input file in a message. Make sure to wrap it with CODETAGS. That will make this theoretical discussion practical.
# 6  
Old 01-18-2011
Hi joyeyg,

Sorry, I have not tried to be theoretical.
There is no codetags.
I just want to search this file find the .SQL scripts and compare them to a file that i have.
There are two other sql script names in this file and i can find them easily but this one has no space before it, in reality when my job is running i would not know the variable name or the script name etc

This is a snipit of code from my input file.
All the following code is on one line.
...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 ...

Thanks
# 7  
Old 01-18-2011
Please post code and data in "Code Tags".

What this means is do a Windows highlight of the code or data in your post then click on the "Wrap [CODE] tags around selected item" toolbar button.
Hover the mouse over the various icons on the toolbar to find the right toolbar icon. On my screen the correct toolbar item appears to be greyed out ... but it works once you can find it. The faint icon looks like a finger pointing at the word "CODE" but at 1024/768 screen resolution you need a magnifying glass and a big torch to read it.

Once posted in "Code Tags" other posters can cut/paste your code or data without corruption or unwanted formatting (like loss of spacing).

When your post is about subtle processing issues with different spacing in the data, posting samples with and without the problem is important.

Quote:
How I have a very long string and within that string I am trying to get proc file names
Precision is everything in computing. Exactly how long is "very long"?





Quote:
This is a snipit of code from my input file.
All the following code is on one line.
...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 ...
Sorry to be blunt, but in SQL programming terms this is total gibberish. It looks like a mixture of unix script and bits of SQL with additional "..." strings.
We don't mind if you post some practice posts, but please post the entire unix script in "Code Tags", blanking anything confidential with X's.
If you can cut/paste the code from your post and it is identical, we can do the same.


... and while I am on my high horse, the correct spelling is "snippet". LOL

Last edited by methyl; 01-18-2011 at 08:25 PM.. Reason: Corrections, additions and rants.
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

5. 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

6. 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

7. 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

8. 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
Login or Register to Ask a Question