Sponsored Content
Top Forums Shell Programming and Scripting scripting/awk help : awk sum output is not comming in regular format. Pls advise. Post 302369188 by Skaperen on Friday 6th of November 2009 07:47:11 PM
Old 11-06-2009
If all the numbers are integers, you can use %d (or %u if always positive) instead of %.f
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Output in a particular format using AWK

Hi All, I am trying to check if if column 5 is greater than 90. If greater it will print the term in column 6, else if all are within limit, then it will output "Size is within limit". I can't seem to do that with the below code. The output should only be 1 statement of "Size is within the... (4 Replies)
Discussion started by: Raynon
4 Replies

2. Shell Programming and Scripting

[need help] output format from awk

hi all, i have a problem with my nawk command output below is the description : nawk $12 == "00008001" { cnt++;cs_cd } END {for(cd in cs_cd) print cd, cs_cd } 2007020814.TDR output : 133 123 desire output: 133,123,.... please advices thank you so much (6 Replies)
Discussion started by: bucci
6 Replies

3. Shell Programming and Scripting

awk - format output

Input file1 zone: BAU_SERVER1 C0:50:76:01:C6:20:00:12; 50:06:01:69:3B:20:14:8B; 50:06:01:60:3B:20:14:8B zone: BAU_SERVER2 C0:50:76:01:C6:20:00:08; 50:06:01:69:3B:20:14:8B; 50:06:01:60:3B:20:14:8B zone: ... (4 Replies)
Discussion started by: greycells
4 Replies

4. Shell Programming and Scripting

awk to format an output

awk experts, I have in put file with time stamp followed by "," separated data. same patern continues. The output need time stamp in first columns and data total in 2nd columns. Input file T 9:15 d0,1,3,3 d1,2,1,1 d2,3,1,5 e1,1,1,1 T 9:30 d0,1,1,1 d1,2,3,2 d3,1,2,1... (10 Replies)
Discussion started by: arv_cds
10 Replies

5. UNIX for Dummies Questions & Answers

after awk-> format output

hi i have a awk command with several querys.... awk 'FS="|""; print $4, $5, $6...etc.... $4 gives me the date 20120304 $5 is timestamp 101023 I want to format these in 2012.03.04 or 2012/03/04 10:10:23 but have no idea, if this is possible with format-parameters in the awk... (2 Replies)
Discussion started by: Jazzmatazz
2 Replies

6. UNIX for Dummies Questions & Answers

AWK: add and sum line in output

Hi, I have this output: extended device statistics device r/s w/s kr/s kw/s wait actv svc_t %w %b sd1 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0 0 sd2 0.1 2.9 2.6 24.8 0.0 0.1 21.0 0 1 sd3 0.1 2.9 2.7 24.8 0.0 ... (9 Replies)
Discussion started by: mjnman
9 Replies

7. Shell Programming and Scripting

How to sum multiple column output with awk ?

Hi Experts, I am trying to sum multiple columns and rows with awk , I want the sum of : 1] Horizontal Sum: (rows sum): 2] Vertical Sum: (Column's sum] details: # cat file1 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 40 31 32 33 34 35 36 37 38 39 70 41 42 43 44... (2 Replies)
Discussion started by: rveri
2 Replies

8. Shell Programming and Scripting

awk - output comming strange: for operator ~ and == .

Hi awk experts, I am getting a strange output , may be it is normal but I am unable to comprehend, When Using == operator it is showing correct: # ls -l | awk '{for (i=0;i<=NF;i++) if ( $i =="info" )print $1,$6,$7,$8,$9}' drwx------ Jan 17 10:44 info But When using ~ (equal )... (4 Replies)
Discussion started by: rveri
4 Replies

9. Shell Programming and Scripting

Format output using awk

Hello all , need help with this ... Input File DEV % POOL 0CB4 FBA 2211300 81792 4 IE RAID-5(3+1) R5_EFD100_1 - - 1805376 82 IF RAID-1 M2_FC300_1 - ... (4 Replies)
Discussion started by: greycells
4 Replies

10. Shell Programming and Scripting

Format output with blocks - awk

Format output with blocks - Awk ZONESET_A,DBP02_HBA0,DC01,20:00:00:25:b5:b9:a0:28,10,port-channel20,01-VB2 ZONESET_A,DBP02_HBA0,DC01,50:00:14:42:a0:72:74:00,10,fc4/30,O1-CORE-D ZONESET_A,dc01vb,DC01,20:00:00:25:b5:b0:a0:13,10,fc1/24,01-VB1... (1 Reply)
Discussion started by: greycells
1 Replies
integer(3perl)						 Perl Programmers Reference Guide					    integer(3perl)

NAME
integer - Perl pragma to use integer arithmetic instead of floating point SYNOPSIS
use integer; $x = 10/3; # $x is now 3, not 3.33333333333333333 DESCRIPTION
This tells the compiler to use integer operations from here to the end of the enclosing BLOCK. On many machines, this doesn't matter a great deal for most computations, but on those without floating point hardware, it can make a big difference in performance. Note that this only affects how most of the arithmetic and relational operators handle their operands and results, and not how all numbers everywhere are treated. Specifically, "use integer;" has the effect that before computing the results of the arithmetic operators (+, -, *, /, %, +=, -=, *=, /=, %=, and unary minus), the comparison operators (<, <=, >, >=, ==, !=, <=>), and the bitwise operators (|, &, ^, <<, >>, |=, &=, ^=, <<=, >>=), the operands have their fractional portions truncated (or floored), and the result will have its fractional portion truncated as well. In addition, the range of operands and results is restricted to that of familiar two's complement integers, i.e., -(2**31) .. (2**31-1) on 32-bit architectures, and -(2**63) .. (2**63-1) on 64-bit architectures. For example, this code use integer; $x = 5.8; $y = 2.5; $z = 2.7; $a = 2**31 - 1; # Largest positive integer on 32-bit machines $, = ", "; print $x, -$x, $x + $y, $x - $y, $x / $y, $x * $y, $y == $z, $a, $a + 1; will print: 5.8, -5, 7, 3, 2, 10, 1, 2147483647, -2147483648 Note that $x is still printed as having its true non-integer value of 5.8 since it wasn't operated on. And note too the wrap-around from the largest positive integer to the largest negative one. Also, arguments passed to functions and the values returned by them are not affected by "use integer;". E.g., srand(1.5); $, = ", "; print sin(.5), cos(.5), atan2(1,2), sqrt(2), rand(10); will give the same result with or without "use integer;" The power operator "**" is also not affected, so that 2 ** .5 is always the square root of 2. Now, it so happens that the pre- and post- increment and decrement operators, ++ and --, are not affected by "use integer;" either. Some may rightly consider this to be a bug -- but at least it's a long-standing one. Finally, "use integer;" also has an additional affect on the bitwise operators. Normally, the operands and results are treated as unsigned integers, but with "use integer;" the operands and results are signed. This means, among other things, that ~0 is -1, and -2 & -5 is -6. Internally, native integer arithmetic (as provided by your C compiler) is used. This means that Perl's own semantics for arithmetic operations may not be preserved. One common source of trouble is the modulus of negative numbers, which Perl does one way, but your hardware may do another. % perl -le 'print (4 % -3)' -2 % perl -Minteger -le 'print (4 % -3)' 1 See "Pragmatic Modules" in perlmodlib, "Integer Arithmetic" in perlop perl v5.14.2 2010-12-30 integer(3perl)
All times are GMT -4. The time now is 06:42 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy