plz, i wait your help, AWK problem


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting plz, i wait your help, AWK problem
# 8  
Old 06-27-2010
So the array is unecessary:

Code:
awk '$3 == 1 && $5 == "tcp" {
  $1 == "+" && node_plus += $6
  $1 == "-" && node_minus += $6
  print $2, node_plus, node_minus, \
    node_plus - node_minus
    }' OFS='\t' infile

# 9  
Old 06-27-2010
is this correct if i want only for node 1

Code:
($5 == "tcp" && $3=="1") {
  $1 == "+" && node_plus[$3] += $6
  $1 == "-" && node_minus[$3] += $6
  print $2, node_plus[$3], node_minus[$3], \
    node_plus[$3] - node_minus[$3]
    }


Last edited by radoulov; 06-27-2010 at 07:11 PM.. Reason: Added code tags!
# 10  
Old 06-27-2010
Yes, but the arrays are redundant, see my previous post.
# 11  
Old 06-27-2010
i try your awk program and l reply the result
please how exactly write the program, like this script or other:

Code:
BEGIN{}

awk'$3 == 1 && $5 == "tcp" {
  $1 == "+" && node_plus += $6
  $1 == "-" && node_minus += $6
  print $2, node_plus, node_minus, \
    node_plus - node_minus
    }' OFS='\t' infile
END{""}


Last edited by Scott; 06-27-2010 at 07:40 PM.. Reason: Code tags
# 12  
Old 06-27-2010
i try your awk program and l reply the result
please how exactly write the program, like this script or other:

Code:
BEGIN{}

awk'$3 == 1 && $5 == "tcp" {
  $1 == "+" && node_plus += $6
  $1 == "-" && node_minus += $6
  print $2, node_plus, node_minus, \
    node_plus - node_minus
    }' OFS='\t' infile
END{""}


---------- Post updated at 05:28 PM ---------- Previous update was at 05:19 PM ----------

plz
i have the following result :
Code:
[asaadaoui@elec ~]$ awk -f try.awk salem.tr> try.txt
awk: try.awk:4: awk '$3 == 1 && $5 == "tcp"{
awk: try.awk:4:     ^ invalid char ''' in expression

plz, how exactly i write the program

Moderator's Comments:
Mod Comment Please use code tags


---------- Post updated at 06:11 PM ---------- Previous update was at 05:28 PM ----------

Hi Radoulov,
Congratulation
The program is correct

i wrote the following program :

Code:
BEGIN { node_plus=0;node_minus=0; }
{

$3 == 1 && $5 == "tcp"
{
  $1 == "+" && node_plus += $6
  $1 == "-" && node_minus += $6
  print $2, node_plus, node_minus, \
    node_plus - node_minus
}
} 
END {""}

and I have the following part of result ( tracefile ):
Code:
0.02 40 0 40
0.02 40 40 0
0.02 80 40 40
0.02 80 80 0
0.025032 80 80 0
0.025032 120 80 40
0.025032 120 120 0
0.025032 120 120 0
0.025032 160 120 40
0.025032 160 160 0
0.030064 160 160 0
0.030064 200 160 40
0.030064 200 200 0
0.030064 200 200 0
0.030064 240 200 40
0.030064 240 240 0
0.035096 240 240 0
................
.................
................

thank you very much, Sir RADOULOV.

Last edited by radoulov; 06-28-2010 at 09:22 AM.. Reason: Code tags
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Windows & DOS: Issues & Discussions

Plink wait problem

Hi, I have run into a problem to which i can't seem to find any solution, posting here is my last resort. Problem: I am using plink to access my router and run a few configuration commands. When in enter configurations mode, instead of sending next command plink keeps on waiting for manual... (7 Replies)
Discussion started by: zaainabbas
7 Replies

2. Shell Programming and Scripting

[SOLVED] Problem in wait statement

Iam having a script which is used to load users and dumpfile in any given schema.Iam trying to autolog the script and have added two fucntion in it. function init_stdout_redirect { OUT_LOG=$1 OUT_PIPE=$(mktemp -u) # Create the output pipe mkfifo $OUT_PIPE # Save stdout and... (15 Replies)
Discussion started by: Vikram_Tanwar12
15 Replies

3. Shell Programming and Scripting

wait problem

Hello, I have been trying to figure out why the wait isnt waiting for the sleep process to complete till now and have found out that since sleep runs as different process and not a child process the wait isnt waiting. script: cat test|while read i do echo $i sleep 30 & done wait ps... (4 Replies)
Discussion started by: wannalearn
4 Replies

4. Shell Programming and Scripting

Interpretion problem. Plz Help me guys.

Hey friends, below mentioned script is giving me proper o/p which can be “1” or “2” echo select status_ac from db_acct where acct_num='$1'" | dbaccess elstest Now I want to interpret the o/p as follows. If o/p is 1 then “YES” If o/p is 2 then “No” And to do this I have modified above... (2 Replies)
Discussion started by: anushree.a
2 Replies

5. Shell Programming and Scripting

wait command - cat it wait for not-chile process?

Did not use 'wait' yet. How I understand by now the wait works only for child processes, started background. Is there any other way to watch completion of any, not related process (at least, a process, owned by the same user?) I need to start a background process, witch will be waiting... (2 Replies)
Discussion started by: alex_5161
2 Replies

6. UNIX for Dummies Questions & Answers

have a problem with if elif loop .. plz help me with the script

count2=0 var2=NOT if then echo"Loop1" command="egrep ',$var1," if then echo "the command is OR" command=$command"|,$var3," echo "$command" elif then command=$command"| egrep ',$var3," else ... (4 Replies)
Discussion started by: Syms
4 Replies

7. UNIX for Advanced & Expert Users

problem while getting the response back..plz help

Hi ALL: I am not able to get the response back from weblogic in the shell script. The weblogic server in different account. I am able to login to that account and bring the server up but while doing a ping, the script is failing. While the same script is running fine if I run it on the account... (1 Reply)
Discussion started by: splax
1 Replies

8. UNIX for Dummies Questions & Answers

I/O wait Problem

When running top, I notice a bit more I/O wait time than usual. Is there a tool or piece of software out there that can me help evaluate the performance of these operations on my machine? Thanks! (5 Replies)
Discussion started by: unavb
5 Replies

9. Linux

Mandrake 8.00 installation/Booting problem...Plz Help

Hey everyone, I'm new to the forum. I have a problem with Mandrake 8.00; i have installed it on my old PC with no problems (none mentioned) but on re-booting after the installation it just hangs after listing the devices: Hard Disk, CD-ROM & Floppy A. I have installed it on Packard Bell with... (2 Replies)
Discussion started by: sybella1
2 Replies

10. UNIX for Dummies Questions & Answers

Multiboot problem Help plz??

I have installed Win98 OS .......1st then RH7.2 with GRUB bootloader okay i.e in the Grub there is two choices 1-Linux 2-Dos also I install bootloader of linux in MBR -master boot record- when select Linux an error : ... (6 Replies)
Discussion started by: atiato
6 Replies
Login or Register to Ask a Question