Sponsored Content
Top Forums Shell Programming and Scripting How to print more than online using awk Post 302078103 by matrixmadhan on Wednesday 28th of June 2006 02:44:33 AM
Old 06-28-2006
Quote:
Originally Posted by newlearner
Thanks for your help madhan. It is working fine. But I found some lines with more feilds in the first line and $7 is not validating.

For this I modified the code to
firststring=`awk -F"server_elapsed = " '/server_elapsed/ { if( $2 > 0.100 ) { print "server_elapsed="$2"|"} }' tran.log`
and the above line is working fine.

But the issue with number lines in the select statement they are not constant i.e 4.

I am getting with more like 1 ....50.

Would u please suggest me how to deal with this.

Thanks for your kind reply.
here it is,
i should have thought earlier
Code:
#! /usr/bin/ksh

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`

exit 0

 

5 More Discussions You Might Find Interesting

1. 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

2. 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

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

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

5. 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
IGAWK(1)							 Utility Commands							  IGAWK(1)

NAME
igawk - gawk with include files SYNOPSIS
igawk [ all gawk options ] -f program-file [ -- ] file ... igawk [ all gawk options ] [ -- ] program-text file ... DESCRIPTION
Igawk is a simple shell script that adds the ability to have ``include files'' to gawk(1). AWK programs for igawk are the same as for gawk, except that, in addition, you may have lines like @include getopt.awk in your program to include the file getopt.awk from either the current directory or one of the other directories in the search path. OPTIONS
See gawk(1) for a full description of the AWK language and the options that gawk supports. EXAMPLES
cat << EOF > test.awk @include getopt.awk BEGIN { while (getopt(ARGC, ARGV, "am:q") != -1) ... } EOF igawk -f test.awk SEE ALSO
gawk(1) Effective AWK Programming, Edition 1.0, published by the Free Software Foundation, 1995. AUTHOR
Arnold Robbins (arnold@skeeve.com). ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +--------------------+-----------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +--------------------+-----------------+ |Availability | SUNWgawk | +--------------------+-----------------+ |Interface Stability | Volatile | +--------------------+-----------------+ NOTES
Source for gawk is available on http://opensolaris.org. Free Software Foundation Nov 3 1999 IGAWK(1)
All times are GMT -4. The time now is 08:26 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy