Couple of easy questions for experts on awk/sed

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Couple of easy questions for experts on awk/sed
# 1  
Old 06-05-2013
Couple of easy questions for experts on awk/sed

Hello Experts..
I have 3-4 C codes with Oracle SQL statements embedded. All the SQL statements starts with EXEC SQL keyword and ends with ;. I want to extract all the SQL statements out of these codes.
I did awk '/^[ ]EXEC SQL/,/\;/' inputFile (I use this on all of the codes individually). That worked fine. I have couple of questions:

1. How to make searching in awk (non GNU) a case insensitive affair? EXEC SQL or exec sql should both be selected.
2. All the tables starts with "T_". How can I make all the tables upper case ones? E.g. t_table should become T_TABLE in output.

Thanks in advance !

---------- Post updated at 09:40 AM ---------- Previous update was at 09:28 AM ----------

I guess I got answer to 1st questions:
I can do something like this:
[Ee][Xx][Ee][cC] [sS][qQ][Ll]. Smilie

Last edited by juzz4fun; 06-05-2013 at 10:36 AM..
# 2  
Old 06-05-2013
You could also use awk string functions tolower or toupper:
awk 'tolower($0) ~ /exec sql/' file

awk 'toupper($0) ~ /EXEC SQL/' file

These functions can be used for your 2nd problem as well.
# 3  
Old 06-05-2013
Yoda, that is awesome. Didn't knew that there are such functions in awk Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Couple of questions wth grep/sort

I have different things that I was trying to do but am kind of struggling with this since I'm a Linux noob. The backround is that I have two files with student names in the same directory, and each file lists the student name, their major and their grade level. What is the most efficient way to... (6 Replies)
Discussion started by: tastybeer
6 Replies

2. UNIX for Dummies Questions & Answers

Couple of newbie Unix questions

I entered a command at the prompt and it's interactive (not background). It gathers some stats and writes them to a file. I want to see this job running and what it's doing - I/O especially and maybe CPU and stuff. What can do to see this (say using a second session?) I know it's a long job but... (3 Replies)
Discussion started by: ido1957
3 Replies

3. Solaris

Couple logadm questions

My logadm.conf is below. Is there a way to match a log file that appends the time/date stamp after the log file? Also, a 0 is being appended onto the files I'm compressing and having rotated. Is there a way to fix that? /var/apache/tomcat55/logs/catalina.out -C 30 -P 'Fri Jun 18 16:48:55... (5 Replies)
Discussion started by: LittleLebowski
5 Replies

4. IP Networking

Couple of quick IP Routing questions

Hi 1) Is the MIB II table that can be accessed through the function m2IpRouteTblEntryGet() the same as the IP Routing table that the IP layer uses to do its routing work? 2) Is there a set of API functions, other than m2IpRouteTblEntryGet(), that are available to access entries in the IP Routing... (2 Replies)
Discussion started by: nzeidat
2 Replies

5. HP-UX

Couple of questions.

Right now I am a Microfocus COBOL programmer, working on a HP-UX system. I want to now get Certified as a HP Certified Systems Administrator. I ordered a book from amazon and will start with it. I also will be working at my job with someone who applies the patches and things as we do NOT have a... (3 Replies)
Discussion started by: nixie21
3 Replies

6. UNIX for Advanced & Expert Users

Apache ssl questions for experts

Hi, I have configured apache 2.0.59 with mod_ssl to set up a proxy to my app server. Incomming traffic https outgoing http. The listen port for the ssl port is 8050 not 443. When I start the server and I test it i get an error message. I googled for it and found the following expaination. ... (3 Replies)
Discussion started by: elvis00
3 Replies

7. Debian

A couple of grub questions.

1) After I install a new kernel in Debian Sarge, it updates my menu.lst file for grub, but incorrectly. It assumes it should boot from partition hd0,0, but this is incorrect. How do I change this faulty assumption? 2) If grub fails to find a kernel, grub allows me to enter a path to... (1 Reply)
Discussion started by: akbar
1 Replies

8. Linux

Attn! A couple quick questions about Linux [Help]

Hi guys!! I was wondering if you can help me with a couple quick questions in order for me to understand it better... Any help would be appreciated and i would like to say thanks!! In advanced... Ok here goes... (I think these are pretty basic, but i just want to clarify) 1. What would be the... (2 Replies)
Discussion started by: kyoist
2 Replies

9. Shell Programming and Scripting

Need help - from awk, sed experts

Hi , I have a file as below. Contents of the file are -------------------- aaaaaaaaaaa aaaaaaaaaaa aaaaaaaaaaa aaaaaaaaaaa aaaaaaaaaaa bbbbbbbbbbb ccccccccccc ddddddddddd aaaaaaaaaaa aaaaaaaaaaa aaaaaaaaaaa aaaaaaaaaaa aaaaaaaaaaa bbbbbbbbbbb (4 Replies)
Discussion started by: Srini75
4 Replies
Login or Register to Ask a Question

Featured Tech Videos