Sponsored Content
Full Discussion: What's wrong with my awk
Top Forums Shell Programming and Scripting What's wrong with my awk Post 302883940 by yanglei_fage on Thursday 16th of January 2014 08:44:57 PM
Old 01-16-2014
What's wrong with my awk

file1:

Code:
maximum_delay time: 102.794 ms
maximum_delay time: 92.977 ms
maximum_delay time: 98.895 ms
maximum_delay time: 96.891 ms
maximum_delay time: 86.966 ms
maximum_delay time: 95.91 ms
maximum_delay time: 98.921 ms
maximum_delay time: 89.881 ms
maximum_delay time: 92.931 ms
maximum_delay time: 99.901 ms
maximum_delay time: 94.855 ms
maximum_delay time: 89.062 ms
maximum_delay time: 95.905 ms
maximum_delay time: 97.9 ms
maximum_delay time: 92.994 ms
maximum_delay time: 96.897 ms
maximum_delay time: 101.905 ms
maximum_delay time: 89.056 ms
maximum_delay time: 86.851 ms
maximum_delay time: 95.024 ms
maximum_delay time: 96.917 ms
maximum_delay time: 95.883 ms
maximum_delay time: 92.063 ms
maximum_delay time: 86.859 ms
maximum_delay time: 86.991 ms
maximum_delay time: 95.897 ms
maximum_delay time: 97.908 ms
maximum_delay time: 96.912 ms
maximum_delay time: 89.959 ms
maximum_delay time: 91.963 ms
maximum_delay time: 97.021 ms
maximum_delay time: 96.912 ms
maximum_delay time: 93.062 ms
maximum_delay time: 93.053 ms
maximum_delay time: 98.909 ms
maximum_delay time: 88.036 ms
maximum_delay time: 94.908 ms
maximum_delay time: 92.874 ms
maximum_delay time: 96.915 ms
maximum_delay time: 97.899 ms
maximum_delay time: 92.852 ms
maximum_delay time: 97.896 ms
maximum_delay time: 76.993 ms
maximum_delay time: 101.906 ms
maximum_delay time: 93.038 ms
maximum_delay time: 80.976 ms
maximum_delay time: 98.017 ms
maximum_delay time: 95.909 ms
maximum_delay time: 100.009 ms
maximum_delay time: 93.011 ms

Code:
lyang001@lyang001-OptiPlex-9010:/tmp$ cat file1 |awk '
(NR==1){min=$3;max=$3;typ=$4}
($2<min){min=$3}
($2>max){max=$3}
{tot+=$3}
END{print "min: " min " " typ " avg: " tot/NR " " typ " max: " max " " typ }'


it gets: 
min: 102.794 ms avg: 94.1613 ms max: 93.011 ms

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

whats wrong with this awk???

while read LINE; do echo |awk -v LIN="${LINE}" '{print substr(LIN,1,7)","substr(LIN,8,5)" ,"substr(LIN,14,10)","substr(LIN,24,6)" ,"substr(LIN,30,8)}'; done < exp1.txt exp1.txt = 1234 grgrg 203902 ksdjh oehr weo why it doesn't work?? thanks. (5 Replies)
Discussion started by: george_
5 Replies

2. Shell Programming and Scripting

what is wrong with my awk statment?

I am looking to find something in the hour(in field $2) of 03:00:07 and 04:00:07 and 05:00:07 and must contain something in field 4... why doesn't below command work? I try to use grep .. but since I am running this in loop, it's best I use the awk .. can someone please advise.. I am pretty... (1 Reply)
Discussion started by: hankooknara
1 Replies

3. UNIX for Dummies Questions & Answers

what is wrong in this awk or grep ....

hi champs, i have a strange problem, let , i have a array1, whose 1st character is ${array1}=h let i want to search test.txt by awk/grep where the 1st character is the ${array1}.... if i am seraching by awk/grep by using variable..it return no rows from test.txt... awk -v find=${array1}... (2 Replies)
Discussion started by: manas_ranjan
2 Replies

4. Shell Programming and Scripting

awk... what is wrong?

Hi there, what is wrong with this? grep ">>" alarms_temp | awk '{print substr($5, 2), $7}' | read var1 var2 echo "$var1" echo "$var2" Both variable are empty, but if i run: grep ">>" alarms_temp | awk '{print substr($5, 2), $7}' I have: 0 9 as a result. (2 Replies)
Discussion started by: marimovo
2 Replies

5. Shell Programming and Scripting

What's wrong with this awk?

ZSCORE=$(awk "BEGIN {if($STDEVIATE>0) {print ZSCORER=$(awk "BEGIN{print (${ALL} - ${AVERAGE}) / ${STDEVIATE}}")}else print "0"}") awk: fatal: division by zero attempted awk: BEGIN {if(0==0) {print ZSCORER=}else print 0} awk: ^ syntax error ALL=9 STDEVIATE=0... (2 Replies)
Discussion started by: SkySmart
2 Replies

6. Shell Programming and Scripting

what's wrong with my awk line?

] && { echo "The free mem need to be more than 2G" } (3 Replies)
Discussion started by: yanglei_fage
3 Replies

7. Shell Programming and Scripting

what's wrong with my awk

echo "abc:bcd" |awk '{split($0,b,":");print "b" is good }' I want to "bcd" is good , anything is wrong with my, please don't change my thought with split, I just want to know what's wrong :o (1 Reply)
Discussion started by: yanglei_fage
1 Replies

8. Shell Programming and Scripting

What's wrong with this awk?

I have a file and if I'm doing following action on that file it's coming up correctly awk -F"," '/DATA_TYPE/ { cnt += $3 } END { print " DATA_TYPE count=" cnt}' inter DATA_TYPE count=19593131 now if I'm changing same AWK, so that now it can accept variable, then it's somehow not working.... (3 Replies)
Discussion started by: manas_ranjan
3 Replies

9. Shell Programming and Scripting

What is wrong with my awk code?

Hi there, I am trying to select a number of lines based on the lat. lon columns in a file but my awk code gives me empty result. Here is my file: 20100213 102212 33.1185 39.4078 2.9 20100214 141753 33.1058 39.9068 2.9 20100218 115828 33.1907 39.3575 2.9 20100225 220001 33.1932 39.9448... (10 Replies)
Discussion started by: johankor
10 Replies

10. Shell Programming and Scripting

What is wrong with my awk command?

The below code usually works when the value for the COLUMN variable is numerical. but im in a situation where the number of fields in a file is not definitive. it changes. but what is static is that the value i want to retrieve from the log is 3 fields from the last field. which is what i... (9 Replies)
Discussion started by: SkySmart
9 Replies
ppmtosixel(1)						      General Commands Manual						     ppmtosixel(1)

NAME
ppmtosixel - convert a portable pixmap into DEC sixel format SYNOPSIS
ppmtosixel [-raw] [-margin] [ppmfile] DESCRIPTION
Reads a portable pixmap as input. Produces sixel commands (SIX) as output. The output is formatted for color printing, e.g. for a DEC LJ250 color inkjet printer. If RGB values from the PPM file do not have maxval=100, the RGB values are rescaled. A printer control header and a color assignment table begin the SIX file. Image data is written in a compressed format by default. A printer control footer ends the image file. OPTIONS
-raw If specified, each pixel will be explicitly described in the image file. If -raw is not specified, output will default to com- pressed format in which identical adjacent pixels are replaced by "repeat pixel" commands. A raw file is often an order of magni- tude larger than a compressed file and prints much slower. -margin If -margin is not specified, the image will be start at the left margin (of the window, paper, or whatever). If -margin is speci- fied, a 1.5 inch left margin will offset the image. PRINTING
Generally, sixel files must reach the printer unfiltered. Use the lpr -x option or cat filename > /dev/tty0?. BUGS
Upon rescaling, truncation of the least significant bits of RGB values may result in poor color conversion. If the original PPM maxval was greater than 100, rescaling also reduces the image depth. While the actual RGB values from the ppm file are more or less retained, the color palette of the LJ250 may not match the colors on your screen. This seems to be a printer limitation. SEE ALSO
ppm(5) AUTHOR
Copyright (C) 1991 by Rick Vinci. 26 April 1991 ppmtosixel(1)
All times are GMT -4. The time now is 09:14 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy