Please Help


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Please Help
# 1  
Old 03-11-2008
Please Help

Dear All

I have a group of patterns which look like this :

2 20080223_15:12:15.259 ISC-Libya BritishTelecom2 104 IAM 20104016641 218925164479 b 3330 ACM b 3337 ANM f 78309 REL b 78520 RLC :COMMA: NCI=10,FCI=2001,CPC=0A,TMR=00,USI: :COMMB: BCI=0434,OBI=01: :RELCAUSE:10:

I want a script that check two conditions in the same time:

1- Check if $14== "ANM"

if this condition is applied then it subtracts $13- $10 if the result is less than or equal 800 then it prints the whole line.

I want the output which will be large number of lines to be directed to a separate file.

So please can anyone write me this script

Regards
Zanetti
# 2  
Old 03-11-2008
Code:
cat temp.txt | perl -ne '@a = split(/\s/, $_); if($a[13] eq "ANM"){ if ( ($a[12] - $a[9])  <= 800){ print $_}}' > output.txt

Adjust to suit. This seems to work for me.

ShawnMilo
# 3  
Old 03-11-2008
Thanks but i think this is perl language , can you customize one using AWK
Can this work:
{
for(i>2 ,i<=NF,i++)
if( i>2 && $14=="ANM"&& $13-$9 <=800){
print $0
break
}
}

Can this work ?
# 4  
Old 03-12-2008
Can you help me guys?

Dear All

I have a group of patterns which look like this :

2 20080223_15:12:15.259 ISC-Libya BritishTelecom2 104 IAM 20104016641 218925164479 b 3330 ACM b 3337 ANM f 78309 REL b 78520 RLC :COMMA: NCI=10,FCI=2001,CPC=0A,TMR=00,USI: :COMMB: BCI=0434,OBI=01: :RELCAUSE:10:

I want a script that check two conditions in the same time:

1- Check if $14== "ANM"

if this condition is applied then it subtracts $13- $10 if the result is less than or equal 800 then it prints the whole line.

I want the output which will be large number of lines to be directed to a separate file.
Please i want it using AWK

So please can anyone write me this script

Regards
Zanetti
# 5  
Old 03-12-2008
Try this out

Hi

cat filename | awk '$14=="ANM" && ($13-$10) <=800 END {print $0}'

Thank U
Naree
Login or Register to Ask a Question

Previous Thread | Next Thread
Login or Register to Ask a Question