Please guide on awk script...


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Please guide on awk script...
# 1  
Old 10-04-2010
Please guide on awk script...

Hi All,
by running this script its working correct for 3rd awk body but i am not be able to take
"INTELLECT_NY_DEAL_FLD_COUNT=51;" this value inseide the awk.Actually i want to check whether INTELLECT_NY_DEAL_FLD_COUNT=51;
in every row i.e every row shoud contain 51 row if not then it shoud give an error.
Any bady has solution on this please give solution related to this script only, Dont give genarlised solution i am not be able to use it in my script.

count.txt file has records like
Code:
OPICS~CA~EOD~888~2010-10-01 01:01:29~20100930~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
OPICS~CA~EOD~888~2010-10-01 01:01:29~20100930~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
OPICS~CA~EOD~888~2010-10-01 01:01:29~20100930~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
OPICS~CA~EOD~888~2010-10-01 01:01:29~20100930~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
OPICS~CA~EOD~888~2010-10-01 01:01:29~20100930~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
OPICS~CA~EOD~888~2010-10-01 01:01:29~20100930~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
OPICS~CA~EOD~888~2010-10-01 01:01:29~20100930~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Code:
#!/bin/bash
WORK_DIR=/export/opt/rtrupld/autosys/scripts_old
DATA_DIR=/cdirect/rtrupld/incoming/intellect
#LOG=/export/opt/rtrupld/autosys/logs/impIntEurCshFlw.log
data=`ls $WORK_DIR/count.txt`
#propfile=$WORK_DIR/HandoffValidation.properties
INTELLECT_NY_DEAL_FLD_COUNT=51;

 
awk ' END {print NR}' $data
  
  awk -v var=$INTELLECT_NY_DEAL_FLD_COUNT 
  awk ' {          sum=0; 
  
 

       print"::INT:::::",INTELLECT_NY_DEAL_FLD_COUNT
 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,  " tilde count=",sum}
       exit;
        } } else{
 oldsum=sum
 print "oldsum at last",oldsum
 }
   
  }'  $data


Last edited by Franklin52; 10-04-2010 at 06:52 AM.. Reason: Please use code tags!
# 2  
Old 10-05-2010
 
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

if else statement... need guide

read readTerminal terminal_c=$readTerminal if ; then { #Execute the first SQL query } else echo next script fi anything wrong here? (2 Replies)
Discussion started by: ment0smintz
2 Replies

2. UNIX for Dummies Questions & Answers

Guide me please

Hi All, I am kinda struck at one point :wall: need ur help to move further. Query: My inputs files are Expected output: I am sure there should be similar tread relating my query ..but as i couldnt find the details i am posting again. Please direct me to the tread or reply... (1 Reply)
Discussion started by: unibeginner
1 Replies

3. Shell Programming and Scripting

Help: How to convert this bash+awk script in awk script only?

This is the final first release of the dynamic menu generator for pekwm (WM). #!/bin/bash function param_val { awk "/^${1}=/{gsub(/^${1}="'/,""); print; exit}' $2 } echo "Dynamic {" for CF in `ls -c1 /usr/share/applications/*.desktop` do name=$(param_val Name $CF) ... (3 Replies)
Discussion started by: alexscript
3 Replies

4. Solaris

Best guide for Jumpstart

Hi Gurus, Can you please suggest me any good guides for a Beginner to learn Solaris Jumpstart. Thank You, Rama Krishna. (2 Replies)
Discussion started by: rama krishna
2 Replies

5. UNIX and Linux Applications

GD installation guide asking....

Hi, Does anybody success install GD and apply it in linux? I got trying to install it recently. Unfortunately, it seems like got a lot of error message shown :( Thus anybody got success install and use the GD in linux? Can share it with me? I'm using ia64 linux system. Thanks a lot for all... (6 Replies)
Discussion started by: patrick87
6 Replies

6. UNIX for Advanced & Expert Users

installion guide

Hi everyone. I need to install HP-UX 11i and I want user installation guide which shows me how to install HP-UX 11i step by step.:) (1 Reply)
Discussion started by: ahmedbashir
1 Replies

7. UNIX for Dummies Questions & Answers

pls guide this..

in what real time scenerios we write shell scripts in oracle (1 Reply)
Discussion started by: ss4u
1 Replies

8. Solaris

Guide to Samba

Anyone have guide to install samba on solaris 9 I tried couple of times. --How do I go about uninstalling it? bash-2.05# testparm -s > output.file Load smb config files from /usr/local/samba/lib/smb.conf Processing section "" Processing section "" Loaded services file OK. bash-2.05#... (2 Replies)
Discussion started by: brabored
2 Replies
Login or Register to Ask a Question