Does awk ever resolve params ?..


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Does awk ever resolve params ?..
# 8  
Old 02-25-2009
Before we close this thread:

Code:
k=`nawk -v t="${tables[$j]}" '/ETL_VW_SCHEMA/ && $0 ~ ("[.]" t "$") / || /EDW_DB_SCHEMA/ && $0 ~ ("[.]" t "$")' ${graph[$i]}`

Few of my table occurences(${tables[$j]}) are in lower case and this script doesn't quite catch them....and I need the command to take care of lower cases too with the present functionality.
I could have researched on this, but due to time crunch not able to...
Thx !
# 9  
Old 02-25-2009

Use patterns that match both upper and lower case: [Ee][Tt][Ll]...
# 10  
Old 02-26-2009
Hi Johnson,
I am using an array({tables[$j]}) to store all the table names, which means I dont have the luxury of using the exact patterns like [Ee][Tt][Ll].
There are around 200 tables in the list...
So, Is there a way I can direct the shell to convert the lower cased table names to uppercase as soon as it parses and apply the awk command ?.....

Thx !
# 11  
Old 02-26-2009
If I understand correctly you can convert them to upper case inside awk:

Code:
nawk -v t="${tables[$j]}" '/ETL_VW_SCHEMA/ && $0 ~ ("[.]" toupper(t) "$") / ...

But I also believe that you can write the entire program in awk instead of using this inefficient shell/awk mix.

Last edited by radoulov; 02-26-2009 at 12:03 PM.. Reason: lower -> upper
# 12  
Old 02-26-2009
Radoulov,
Code:
nawk -v t="${tables[$j]}" '/ETL_VW_SCHEMA/ && $0 ~ ("[.]" toupper(t) "$") / ...

This will not work in my case as my table list is always in upper case and 90% of the pattern occurences in the search file will be in upper case but there are few cases(which are unknown) where the occurences will be in lower case and we need to address such instances....I guess we need to write up a condition inside awk to check for the case.

Thx !
# 13  
Old 02-26-2009
Just to mention...
I know we can just put in a seperate OR in the awk to check for lower case and resolve the issue:

Code:
nawk -v t="${tables[$j]}" '/ETL_VW_SCHEMA/ && $0 ~ ("[.]" toupper(t) "$") || /ETL_VW_SCHEMA/ && $0 ~ ("[.]" tolower(t) "$")' && .....

But I am sure this will not be a suggestable solution....

Thx !
# 14  
Old 02-27-2009
Or just use:

Code:
toupper($0) ~ "[.]" toupper(t) "$"

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Cannot resolve $variable in awk

My script ---------- for i in `cat n`;do export k=`echo "CSN: "$i` //combining CSN: and value from n echo "$k" awk ''{print "CSN: "$0;}'{_=29}_&&_--' file1|tail -1 >> file2 done In the above script i cannot able to resolve $k in awk command file n contains ------------ 0000 1111 2222... (2 Replies)
Discussion started by: Mohana29_1988
2 Replies

2. Shell Programming and Scripting

Cannot resolve $var in awk

My script ---------- for i in `cat n`;do export k=`echo "CSN: "$i` //combining CSN: and value from n echo "$k" awk ''{print "CSN: "$0;}'{_=29}_&&_--' file1|tail -1 >> file2 done In the above script i cannot able to resolve $k in awk command file n contains ------------ 0000 1111... (0 Replies)
Discussion started by: Mohana29_1988
0 Replies

3. Shell Programming and Scripting

The awk subtraction giving exponential values.Please help resolve it

Hi friends, I have a file list1 which has these 2 columns like 616449 0 434453 1 2151083 0 2226536 0 2132382 0 2136814 0 I have to put the result of col1 -col2 into another file list2 linewise. e.g. It gives the below result if use the below code: awk '{ print $1 - $2 }' list1 >... (2 Replies)
Discussion started by: kunwar
2 Replies

4. Shell Programming and Scripting

Check params for number

I have 2 and three params, both I should make sure thay numbers at one single line insted of checking for each one . Example I wroote the following way.. checking for 2 and three seperately but I shud be able to do it at on statement echo $2 | egrep '^+$' >/dev/null 2>&1 if ; then echo... (2 Replies)
Discussion started by: raopatwari
2 Replies

5. Shell Programming and Scripting

Pass params with Udev

Hello! I'm sorry if this is the false Forum, didn't really knew where to put it... My question: I have serveral USB-Sticks and wrote several Udev-Rules for theme, each Sticks needs to do something else, but all are using the same script (they have common tasks to do) and only some parts are... (2 Replies)
Discussion started by: al0x
2 Replies

6. UNIX for Dummies Questions & Answers

Can any good awk'er resolve this issue?

awk -F^ '{ if ((($1 != "M") && ($5 != "2")) || (($1 != "S") && ($5 != "7"))) print $0}' welcome > welcome1 The "&&" and "||" in the above command is not working with awk. When I run the above command, the same content of welcome is copied to welcome1 without any difference. Your reply is... (12 Replies)
Discussion started by: karthickrn
12 Replies

7. Shell Programming and Scripting

script takes params

i want to write a shell script that can be run as ./deployPortal.sh -version 5.1.2 -portlet -exportall how can i do that? version param is required. bu the others are optional. in first step i only want to read 5.1.2, is portlet selected ? and is exportall selected ?? can you... (2 Replies)
Discussion started by: keromotti
2 Replies

8. Shell Programming and Scripting

sed & awk--get section of file based 2 params

I need to get a section of a file based on 2 params. I want the part of the file between param 1 & 2. I have tried a bunch of ways and just can't seem to get it right. Can someone please help me out.....its much appreciated. Here is what I have found that looks like what I want....but doesn't... (12 Replies)
Discussion started by: Andy Cook
12 Replies

9. UNIX for Dummies Questions & Answers

evaluating params

Hi all, I ve a script like.... TBL=employee sql=`cat abhi.sql` \\ abhi.sql contains ------- select a from $TBL echo $TBL echo $sql SQL=`echo $sql` echo $SQL now i want SQL as select a from employee and as select a from $TBL How can I achieve this? Help appriciated (3 Replies)
Discussion started by: abzi
3 Replies

10. UNIX for Advanced & Expert Users

Change params for time zone

Hi! How ican change parameters for daylight, i mean, i want change the daylight on december first week. I've tried with /usr/lib/tztab but result unsuccessful. (7 Replies)
Discussion started by: agustincm
7 Replies
Login or Register to Ask a Question