![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Variables scope. | dinjo_jo | Shell Programming and Scripting | 13 | 09-10-2008 07:03 AM |
| Doubt??? [scope of variables] | qzv2jm | Shell Programming and Scripting | 1 | 03-04-2008 09:19 AM |
| How to access variables across scripts | javaDev | Shell Programming and Scripting | 1 | 08-13-2007 04:47 AM |
| Access Awk Variables Outside Scope | Amruta Pitkar | UNIX for Advanced & Expert Users | 2 | 10-26-2006 09:35 PM |
| Read variables from Access table | Sn33R | UNIX for Dummies Questions & Answers | 2 | 09-24-2003 01:01 PM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Access Awk Variables Outside Scope
My awk script searches for specified patterns in a text file and stores these values into mem variables.
Once this is done I want to Insert these values into a table. How can I avail of the variable values outside the scope of awk script.... One method that I have tried is to write the variables values into a temp file with delimiters and then read these values from a shell script, form a connection to database and insert the values into table....But I feel this is doing things in a roundabout way.... What wud be a straighter approach ? I dont want to sacrifice the awk script ! The awk script now : Code:
/Total logical records skipped:/ {skiprecs=$5;}
/Total logical records read:/ {readrecs=$5;}
/Total logical records rejected:/ {rejectrecs=$5;}
/Total logical records discarded:/ {discardrecs=$5}
END { totalfailrecs = skiprecs + rejectrecs + discardrecs ;
totalsuccessrecs = readrecs ;
totalrecs = totalfailrecs + totalsuccessrecs ;
printf "Printing the results "
printf ("\n")
printf ("Failed Records : %d\n", totalfailrecs);
printf ("Success Records : %d\n", totalsuccessrecs);
printf ("Total Records : %d\n", totalrecs);
printf ("%d,%d,%d",totalfailrecs,totalsuccessrecs,totalrecs)>>"tempfile"
}
Amruta Pitkar |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|