fetching values using awk and storing into array


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting fetching values using awk and storing into array
# 1  
Old 06-04-2009
fetching values using awk and storing into array

hi all

I am using awk utility to parse the file and fetching two different vaues from two different record of a record set.

I am able to see the result, now i want to store the result and perform some check of each values form database to mark valid and invalid.

could you please help me to write korn shell script.

to fetch all values for first pattern from file: awk '/'"$PATTERN1"'/' $FILE |cut -f3 -d ' '|sed 's/ //g'

to fetch all values for second pattern from file: awk '/'"$PATTERN2"'/' $FILE |cut -f3 -d ' '|sed 's/ //g'

the output is coming like

Pattern1

ABC
DEF
ABC
KLM

Pattern2

123
234
abc
r4e

etc.

i need to call oracle store procedure to check for validaity of these values.

Thanks in Advance

Singhal
# 2  
Old 06-04-2009
One way is to use sqlloader to load the data in a table and validate the data with SQL.
Google for sqlloader if you don't have experience with it.

Regards
# 3  
Old 06-04-2009
i want to pass both pattern values as arguments to a sql stored procedure for validation. i am aware about the sqlloader. i want to store both result set into array and access one by one both to validate. could you give me some example in KSH.

Thanks

Singhal
# 4  
Old 06-04-2009
Quote:
Originally Posted by singhald
i want to pass both pattern values as arguments to a sql stored procedure for validation. i am aware about the sqlloader. i want to store both result set into array and access one by one both to validate. could you give me some example in KSH.

Thanks

Singhal
There are a lot of threads regarding this item, search for sql stored procedure with the search function.

Regards
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Awk: Storing string in array(triangular form)

I have a string like below. Now i want to split this string like below and put the value in the array using awk. I am able to do it using bash but getting no clue for doing it in awk O/P A=0 A=01 A=014 A=0143 A=01438 A=014387 A=0143876 A=01438765 A=014387650 ... (7 Replies)
Discussion started by: siramitsharma
7 Replies

2. Shell Programming and Scripting

storing multiple values in a array variable

Am using a find command in my script .The output may be one or more. I need to store those values in a array and need to access those. Am unable to find the solution . Any help on this will be helpful. if < code> else a=<find command output which gives the file name either 1 or more> if 1... (1 Reply)
Discussion started by: rogerben
1 Replies

3. Shell Programming and Scripting

Array in awk outputs multiple values

Disclaimer: OP is 100% Awk beginner. I use this code on ASCII files I need to report against. awk 'BEGIN { tokens = 0 tokens = 0 tokens = 0 } { for (token in tokens) { if ($1 == token){print $0; tokens++;}}} END {for (token in tokens){ if( tokens ==... (1 Reply)
Discussion started by: alan
1 Replies

4. Shell Programming and Scripting

Extracting fetching values

I have a file like this ############################################ # ParentFolder Flag SubFolders Colateral 1 Source1/Checksum CVA 1 Source1/Checksum Test 1 VaR/Checksum Test2 1 SVaR/Checksum FX 1 ... (6 Replies)
Discussion started by: manas_ranjan
6 Replies

5. Shell Programming and Scripting

help with fetching the values from perlscript

Hi, I have a perl script abc.pl.. #!/usr/bin/perl local ($buffer, @pairs, $pair, $name, $value, %FORM); # Read in text $ENV{'REQUEST_METHOD'} =~ tr/a-z/A-Z/; if ($ENV{'REQUEST_METHOD'} eq "POST") { read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); }else {... (3 Replies)
Discussion started by: puneetkanchi
3 Replies

6. Shell Programming and Scripting

Piping Unix Variable Array values into AWK

#ksh Here is my code: ERRORLIST="43032 12001 12002 12003 12004 34019 49015 49016 49017 49018 49024 49025 49026 58004 72003 12005 12006 12007 12008 12011 12012 16024 16023" for ERROR in ${ERRORLIST} do awk -v l="$lastdate" '/^....-..-../&&$0>l{d=$0}d&&/Error: '"${ERROR}"'/{print... (3 Replies)
Discussion started by: k1ko
3 Replies

7. Shell Programming and Scripting

Problem with lookup values on AWK associative array

I'm at wits end with this issue and my troubleshooting leads me to believe it is a problem with the file formatting of the array referenced by my script: awk -F, '{if (NR==FNR) {a=$4","$3","$2}\ else {print a "," $0}}' WBTSassignments1.txt RNCalarms.tmp On the WBTSassignments1.txt file... (2 Replies)
Discussion started by: JasonHamm
2 Replies

8. Shell Programming and Scripting

storing values in a list or array

i have a file called file.txt having the following entries. 2321 2311 2313 4213 i wnat to store these values in a list and i want to iterate the list using loop and store it in another list (1 Reply)
Discussion started by: KiranKumarKarre
1 Replies

9. Shell Programming and Scripting

saving values in file in an array in awk

hi i am trying to save values in a file in an array in awk..the file is as follows: 0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0, so far i have this: awk 'BEGIN {RS="\n";FS=","} { for(i=1;i<=NR;i++) { for(j=1;j<=NF;j++) { a=$j; } } (4 Replies)
Discussion started by: npatwardhan
4 Replies

10. Shell Programming and Scripting

storing records in awk array

hi i have a file as follows: 1 2 3 4 5 6 i want to store all these numbers in an array using awk.. so far i have: awk '{for(i=1;i<=NR;i++) {a=$1}} END {for(i=1;i<=NR;i++) {printf("%1.11f",a)}}' 1.csv > test however, i am getting all values as zero in the "test" file..... (3 Replies)
Discussion started by: npatwardhan
3 Replies
Login or Register to Ask a Question