How to print more than online using awk


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to print more than online using awk
# 8  
Old 06-28-2006
this should be very simple mistake

Quote:
firststring=`awk -F"=" '/server_elapsed/ { if( $7 > 0.100 ) { print server_elapsed="$7"|"} }' inp`
change the above line to
Quote:
firststring=`awk -F"=" '/server_elapsed/ { if( $7 > 0.100 ) { print "server_elapsed="$7"|"} }' inp`
# 9  
Old 06-28-2006
Thanks for your quick response matrix.

I am sorry. I modified, but still I am getting the below error.

First line of script is working and also the second line.

But it seems the issue with the 3rd line.

Syntax Error The source line is 1.
The error context is
BEGIN{} { if(NR > >>> 1 <<<
awk: 0602-502 The statement cannot be correctly parsed. The source line is 1.
awk: 0602-502 The statement cannot be correctly parsed. The source line is 1.
awk: 0602-540 There is a missing } character.
awk: 0602-540 There is a missing ) character.
server_elapsed= 0.999 | server_elapsed= 0.999 |

The script I am using is inp.sh

firststring=`awk -F"=" '/server_elapsed/ { if( $7 > 0.100 ) { print "server_elapsed="$7"|"} }' inp`
val=`awk -F"=" '/server_elapsed/ { if( $7 > 0.100 ) { print NR } }' inp`
echo $firststring`awk -F"=" 'BEGIN{} { if(NR > '$val' && $0 !~ /^;/ ) { printf $0" " } } END{ printf ";" }' inp`

The input file : inp

-- appl = host = user = / pid = 76 elapsed = 0.000 seconds server_elapsed = 0.999
select emp_no, dept_no
from dept
where deptname like 'IT%'
;
-- appl = host = user = / pid = 76 elapsed = 0.000 seconds server_elapsed = 0.999
select emp_no, dept_no
from dept
where deptname like 'IT%'
and empid=100
;
# 10  
Old 06-28-2006
a final shot,

try this it should definitely work,
Code:

#! /usr/bin/ksh

awk -F"=" '/server_elapsed/ { if( $7 > 0.100 ) { print $7, NR} }' inp | while read val ind
do
awk -F"=" 'BEGIN{ printf "server_elapsed='$val'| " } { if(NR > '$ind' && $0 !~ /^;/ ) { printf
$0" " } else { if( NR > '$ind' && $0 ~ /^;/ ) { exit; } } } END{ printf ";\n" }' inp
done

exit 0

# 11  
Old 06-29-2006
Working great

Thanks for your kind help MATRIX ...

Have a good day and weekend ahead.
Login or Register to Ask a Question

Previous Thread | Next Thread

5 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

awk online to exclude rows

Hello, I have 3 columns like shown below: 1 1800 1900 2 1765 1900 3 1654 2054 4 1326 1499 5 1540 1765 I want only those rows where column 2 and column 3's values don't fall within 1800-1900 both inclusive. My output should only be: 4 1326 1499 5 1540 1765 Is there a quick awk... (3 Replies)
Discussion started by: Gussifinknottle
3 Replies

2. Shell Programming and Scripting

Awk: Print count for column in a file using awk

Hi, I have the following input in a file & need output as mentioned below(need counter of every occurance of field which is to be increased by 1). Input: 919143110065 919143110065 919143110052 918648846132 919143110012 918648873782 919143110152 919143110152 919143110152... (2 Replies)
Discussion started by: siramitsharma
2 Replies

3. Shell Programming and Scripting

Awk problem: How to express the single quote(') by using awk print function

Actually I got a list of file end with *.txt I want to use the same command apply to all the *.txt Thus I try to find out the fastest way to write those same command in a script and then want to let them run automatics. For example: I got the file below: file1.txt file2.txt file3.txt... (4 Replies)
Discussion started by: patrick87
4 Replies

4. Shell Programming and Scripting

How do I get awk to print a " in it's print part?

The line is simple, use " '{ print $1"]"$2"\"$3THE " NEEDS TO GO HERE$4 }' I've tried \", "\, ^" and '"" but none of it works. What am I missing? Putting in the [ between $1 and $2 works fine, I just need to do the same with a ". Thanks. (2 Replies)
Discussion started by: LordJezo
2 Replies

5. UNIX for Dummies Questions & Answers

Is there online help for awk programming

Can anybody please supply me with a good url to get online help to awk programming, with good examples. Yes I've taken that big step in trying to master 'awk' after being able to avoid it for the last couple of years :-) Failing that, is there any good books I can get instead. Many thanks... (4 Replies)
Discussion started by: cfoxwell
4 Replies
Login or Register to Ask a Question