Solution required for awk script


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Solution required for awk script
# 1  
Old 10-04-2010
Solution required for awk script

Hi Jim,

The following script is in working state. But i m having one more problem with awk cmd. Could you tell me how to use any variable inside awk or how to take any variable value outside awk.
My problem is i want to maintain one property file in which i am declaring variable value into that property file and want to use that variable into awk script.
example.
file name:validate.property
INT_EUR=14
INT_TOK=54

now these two variable i want to use it into my shell script. new.sh which i wrote below.
Also one more thing .How to find scane arount 50000 records with minimum time. Actually the following script scan 42000 records in 6 min, i need to scan in 1 min is there any method in shell script.
i Hope u understand my problem. Could you please help me out.

Waiting for you reply.


Code:
#!/bin/bashDATA_DIR=/export/opt/rtrupld/autosys/scripts_olddata=`ls $DATA_DIR/count.txt` awk ' END {print NR}' $data awk ' { sum=0; print "Total lines",NR for(i=1; i<= length($0); i++) {if (substr($0,i,1)=="~" ) {sum++} } if (NR !=1) { print "Total lines:::",NR print "oldsum :::",oldsum print "sum :::",sum if (oldsum==sum){ print "oldsum",oldsum } else { if(oldsum!=sum) {print "error in ", $data," at line ",NR, " tildecount=",sum} exit; } } else{ oldsum=sum print "oldsum at last",oldsum } }' $datacount.txt file contains following data,

INTELLECT~JP~111~0~A~2jp10212991~RR~~~~~~~~~~~~~~~
INTELLECT~JP~111~0~A~2jp10212991~RR~~~~~~~~~~~~~~~
INTELLECT~JP~111~0~A~2jp10212991~RR~~~~~~~~~~~~~~~
INTELLECT~JP~111~0~A~2jp10212991~RR~~~~~~~~~~~~~~~~
INTELLECT~JP~111~0~A~2jp10212991~RR~~~~~~~~~~~~~~~
INTELLECT~JP~111~0~A~2jp10212991~RR~~~~~~~~~~~~~~~
INTELLECT~JP~111~0~A~2jp10212991~RR~~~~~~~~~~~~~~~


Above record each line contains 21 ~ chars in line number 4th number o ~'s are 22 so my script should give line number 4 has an 22 ~'s also my script should take a static value from property file like validate.property
contains records like
INT_EUR=21
INT_TOK=21
INT_CA=54
so on
so that INT_EUR has value =21 so script will check is row 1 have ~=21 or not and so on every line should get scanned and does not match gives n error .
Could you please solve this problem.


Thanks & Regards
Ganesh
# 2  
Old 10-04-2010
Bumping up posts or double posting is not permitted in these forums.

Please read the rules, which you agreed to when you registered, if you have not already done so.

You may receive an infraction for this. If so, don't worry, just try to follow the rules more carefully. The infraction will expire in the near future

Continue here:

https://www.unix.com/shell-programmin...k-command.html

Thank You.

The UNIX and Linux Forums.
This User Gave Thanks to Franklin52 For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed or awk Solution

Hi I am having a csv file like this ahsh,90.82,add,32424,ahha hhdh,98.89,hdhdh,92728,neha hshs,you,97.7,hdhdhd,are,a jsjsj,wonderful,9788,79.9,aheh ahdh,95.5,girl, 2737,jolllI need to add width="100" to the value which is greater than 90 like decimal points but less than 100 Output... (5 Replies)
Discussion started by: kshitij
5 Replies

2. Shell Programming and Scripting

AWK or SED solution

Hello. I have big file data like this(part of file): .... 18210102021010000110 47401000000 021001 5166891.16 021011 5166891.16 18210602010020000110 47401000000 020701 8995421.00 021001 8995421.00 021011 8995421.00 030801 .08 18210604011020000110 47401000000 020701 9048.00 021001... (3 Replies)
Discussion started by: maxoff
3 Replies

3. Shell Programming and Scripting

awk script required to compare two files

HI friends, I have two files. File2 2nd column need to be compared with file1 3rd column.If ID match found, then save in different file as file1 data followed by file2. file1: No;age;id;name 1;24;37h;name1 2;22;67e;name2 4;48;9r;name3 6;67;9i8;name4 file2: exp;id;pos... (9 Replies)
Discussion started by: vasanth.vadalur
9 Replies

4. Shell Programming and Scripting

awk script required

File 1 ################### TRAIU DSKDL; SLLA ;LAKJA KJAJA NSAJAN JANAL AJKJA JAJALA KAKAK JA AKA AKA AJ A A PPIN TRY1 SANT1 PPIN TRY2 SANT2 PPIN TRY3 SANT3 PPIN TRY4 SANT4 PPIN TRY5 SANT5 AJJA NA ANA ANHDJLD ALJALJA AJLJAJD LALJAL ALJALJA ALJALJA (4 Replies)
Discussion started by: jaita
4 Replies

5. Shell Programming and Scripting

Awk solution

Hello! Well, I searched and wasn't able to find a specific example of my dilemma, so hopefully someone could assist? Or maybe there was an example but I missed it? I have two files: file1 = order data file file2 = list of 65,000+ order numbers I would like to extract from 'file1' any... (5 Replies)
Discussion started by: rm -r *
5 Replies

6. Shell Programming and Scripting

awk script required for finding records in 1 file with corresponding another file.

Hi, I have a .txt file (uniqfields.txt) with 3 fields separated by " | " (pipe symbol). This file contains unique values with respect to all these 3 fields taken together. There are about 40,000 SORTED records (rows) in this file. Sample records are given below. 1TVAO|OVEPT|VO... (2 Replies)
Discussion started by: RRVARMA
2 Replies

7. Shell Programming and Scripting

AWK script help required

Hello every one i have a very long file 'file1' like this <K>1</K> </Condition> <Tariff>Rate <Price>1.27</Price> <Interval>30</Interval> </Tariff> </Node> <Node>NonFaF <Tariff>Rate <Price>1.9</Price> <Interval>30</Interval> </Tariff> </Node> </Node> </Node> <Node>FaF (9 Replies)
Discussion started by: Dastard
9 Replies

8. UNIX for Dummies Questions & Answers

CC Solution Required Urgently

Hi there, My question is: If the command cc is executed on obelix, what executable file will be run? Using the results of whereis, which and any other commands you consider necessary, explain why this file is executed. Please help as soon as possible thanks (5 Replies)
Discussion started by: satty
5 Replies

9. Shell Programming and Scripting

Is there a awk solution for this??

I am writing a awk script that gathers certain data from certain fields. I needed a awk solution for this, because it will later become a function in the script. I have the following data that I need output on a single line, but record spans across multilple lines and records are not... (7 Replies)
Discussion started by: timj123
7 Replies
Login or Register to Ask a Question