Sponsored Content
Top Forums Shell Programming and Scripting Arithmetic operation with awk Post 302377281 by cfajohnson on Thursday 3rd of December 2009 03:58:20 PM
Old 12-03-2009
Quote:
Originally Posted by fugitive
Thanks but it only displays line 5 and 6 i want all the lines and line 5 and 6 divided by 1000 and line 7 subtracted from 100 :-)

Code:
awk 'NR == 5 || NR == 6 { $1 = $1 / 1000 }
     NR == 7 { $1 = 100 - $1 }
     { print }
' filename

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Simple arithmetic operation

I have no idea why I can't get this to work, if anybody can help i would appreciate it. #!/bin/bash x=`cat counter.txt | wc -l` y= '$x / 7' printf "%d People have visited this page" $y :confused: (2 Replies)
Discussion started by: paladyn_2002
2 Replies

2. Shell Programming and Scripting

Help with arithmetic operation

I am using egrep to extract numbers from a file and storing them as variables in a script. But I am not able to do any arithmetic operations on the variables using "expr" because it stores them as char and not integers. Here is my code and the error I get. Any help will be appreciated. #!/bin/sh... (3 Replies)
Discussion started by: emjayshaikh
3 Replies

3. UNIX for Dummies Questions & Answers

arithmetic operation on two columns

Hi, All, I have a file, its content is as follows: 100 150 120 135 140 170 I want to insert a column, its content is determined by the difference between the two values in the same line, if the difference is less than 20, the new value is 1, otherwise is 0. after the operation, the... (1 Reply)
Discussion started by: Jenny.palmy
1 Replies

4. Shell Programming and Scripting

How to perform arithmetic operation on date

Hi all, I would appreciate if anyone knows how to perform adding to date. As for normal date, i can easily plus with any number. But when it comes to month end say for example 28 Jun, i need to perform a plus with number 3, it will not return 1 Jul. Thanks in advance for your help. (4 Replies)
Discussion started by: agathaeleanor
4 Replies

5. Shell Programming and Scripting

Arithmetic operation between columns using loop variable

Hi I have a file with 3 columns. say, infile: 1 50 68 34 3 23 23 4 56 ------- ------- I want to generate n files from this file using a loop so that 1st column in output file is (column1 of infile/(2*n+2.561)) I am doing like this: for ((i=1; i<=3; i++)) do a=`echo... (3 Replies)
Discussion started by: Surabhi_so_mh
3 Replies

6. Shell Programming and Scripting

floating point arithmetic operation error

I am writing a script in zsh shell, it fetchs a number from a file using the awk command, store it as a variable, which in my case is a small number 0.62000. I want to change this number by multiplying it by 1000 to become 620.0 using the command in the script var2=$((var1*1000)) trouble is... (2 Replies)
Discussion started by: piynik
2 Replies

7. UNIX for Dummies Questions & Answers

Basic arithmetic operation with awk?

input: Name|Operation rec_10|1+2+2- Output: rec_10|1 Basically I am trying to calculate the result of "the path" in $3 where the operators follow the number and not preceding them like we normally do: rec_10: +1+2-2=1 But I realise (I am sure there is a good reason for that) that awk... (7 Replies)
Discussion started by: beca123456
7 Replies

8. Shell Programming and Scripting

Arithmetic operation in variable

Hi, Here is the script i try to perform arithmetic operation in two variables . git branch -r | while read brname ; do REV_COMMITS=`git rev-list --count $brname` echo "$brname has $REV_COMMITS" (( TOTAL = TOTAL + REV_COMMITS )) echo "in loop" $TOTAL done echo "total is " $TOTAL ... (3 Replies)
Discussion started by: greet_sed
3 Replies

9. Shell Programming and Scripting

Using awk to do arithmetic operation

Hi, I've this following text file FileVersion = 1.03 Filetype = meteo_on_curvilinear_grid TIME = 0 hours since 2016-10-03 12:00:00 +00:00 -6.855 -6.828 -6.801 -6.774 -6.747 -6.719 -6.691 -6.663 -6.634 -6.606 -6.577 -6.548 -6.519 -6.489 TIME = 0 hours since... (2 Replies)
Discussion started by: xisan
2 Replies

10. How to Post in the The UNIX and Linux Forums

How to get defined precision after arithmetic operation using syncsort?

I have to do some arithmetic operation on Field 8 which is calculated by Field 9/Field 7 Suppose i have data like : 0800123456|JAN|2017|JAN|2018|0800123456|0|0.0000|0.00| 0800234567|JAN|2017|JAN|2018|0800234567|4|2.5812|10.32| 0800666666|JAN|2017|JAN|2018|0800666666|2|1.7255|3.45|... (0 Replies)
Discussion started by: pumrao
0 Replies
TM::Coverage(3pm)					User Contributed Perl Documentation					 TM::Coverage(3pm)

NAME
TM::Coverage - Topic Maps, Code Coverage DESCRIPTION
This auxiliary package keeps track of the code coverage. Probably quite irrelevant for a user. Automatically generated for TM (1.44). ---------------------------- ------ ------ ------ ------ ------ ------ ------ File stmt bran cond sub pod time total ---------------------------- ------ ------ ------ ------ ------ ------ ------ blib/lib/TM.pm 96.4 84.5 58.0 93.7 90.6 27.5 89.6 blib/lib/TM/Analysis.pm 100.0 90.9 n/a 100.0 100.0 0.0 97.5 blib/lib/TM/AsTMa/Fact.pm 100.0 n/a n/a 100.0 n/a 0.0 100.0 blib/lib/TM/AsTMa/Fact2.pm 100.0 n/a n/a 100.0 n/a 0.0 100.0 blib/lib/TM/Bulk.pm 76.8 71.4 62.5 85.7 100.0 0.0 75.3 blib/lib/TM/CTM/CParser.pm 65.6 34.3 31.0 84.6 0.0 1.6 52.5 blib/lib/TM/CTM/Parser.pm 90.9 50.0 n/a 100.0 0.0 0.0 79.4 blib/lib/TM/DM.pm 100.0 65.0 66.7 100.0 n/a 0.0 96.5 blib/lib/TM/Graph.pm 99.1 88.5 n/a 100.0 100.0 0.0 97.4 blib/lib/TM/Index.pm 100.0 80.0 60.0 100.0 83.3 0.3 87.8 .../Index/Characteristics.pm 100.0 100.0 n/a 100.0 0.0 0.0 97.0 blib/lib/TM/Index/Match.pm 98.5 87.5 n/a 100.0 100.0 0.5 97.6 blib/lib/TM/LTM/CParser.pm 84.9 45.3 42.7 98.2 0.0 0.2 67.8 blib/lib/TM/LTM/Parser.pm 95.7 62.5 50.0 100.0 0.0 0.0 87.1 blib/lib/TM/Literal.pm 45.8 0.0 11.8 30.0 0.0 0.4 24.2 blib/lib/TM/MapSphere.pm 96.5 84.6 68.8 100.0 100.0 0.0 91.7 .../TM/Materialized/AsTMa.pm 100.0 n/a n/a 100.0 0.0 0.0 95.5 ...ib/TM/Materialized/LTM.pm 100.0 n/a n/a 100.0 0.0 0.0 95.5 .../TM/Materialized/MLDBM.pm 100.0 83.3 n/a 100.0 0.0 0.0 92.6 ...b/TM/Materialized/Null.pm 100.0 n/a n/a 100.0 n/a 0.0 100.0 ...TM/Materialized/Stream.pm 100.0 100.0 100.0 100.0 0.0 0.0 96.0 ...ib/TM/Materialized/XTM.pm 100.0 n/a n/a 100.0 0.0 0.0 96.7 blib/lib/TM/PSI.pm 100.0 n/a n/a 100.0 n/a 0.0 100.0 blib/lib/TM/QL.pm 91.4 61.5 66.7 100.0 50.0 0.1 83.9 blib/lib/TM/QL/CParser.pm 76.2 42.4 41.9 90.3 0.0 9.1 62.0 blib/lib/TM/QL/PE.pm 83.8 77.3 80.0 91.7 0.0 52.5 80.5 blib/lib/TM/QL/TS.pm 65.2 35.4 27.8 70.8 53.3 2.4 56.9 blib/lib/TM/ResourceAble.pm 88.1 87.5 n/a 100.0 100.0 0.0 90.0 .../TM/ResourceAble/MLDBM.pm 100.0 75.0 n/a 100.0 0.0 0.0 94.2 blib/lib/TM/Serializable.pm 94.9 65.6 100.0 100.0 100.0 0.0 84.1 .../TM/Serializable/AsTMa.pm 99.1 87.9 66.7 100.0 100.0 0.0 94.2 ...TM/Serializable/Dumper.pm 100.0 n/a n/a 100.0 0.0 0.0 93.5 ...ib/TM/Serializable/LTM.pm 94.1 n/a n/a 83.3 100.0 0.0 92.0 ...ib/TM/Serializable/XTM.pm 96.3 85.2 72.9 100.0 100.0 0.2 91.5 .../lib/TM/Synchronizable.pm 100.0 75.0 100.0 100.0 100.0 0.0 97.2 ...M/Synchronizable/MLDBM.pm 100.0 50.0 n/a 100.0 0.0 0.0 89.3 ...nchronizable/MapSphere.pm 100.0 63.6 64.3 100.0 100.0 0.0 88.6 ...TM/Synchronizable/Null.pm 100.0 n/a n/a 100.0 0.0 0.0 87.5 blib/lib/TM/Tau.pm 100.0 91.7 80.0 100.0 0.0 0.0 95.6 blib/lib/TM/Tau/Federate.pm 63.2 39.3 n/a 62.5 27.3 0.0 54.5 blib/lib/TM/Tau/Filter.pm 100.0 91.7 66.7 100.0 50.0 0.0 90.0 .../TM/Tau/Filter/Analyze.pm 100.0 n/a n/a 100.0 100.0 0.0 100.0 blib/lib/TM/Tree.pm 100.0 57.1 44.4 100.0 66.7 0.0 88.0 blib/lib/TM/Utils.pm 100.0 50.0 n/a 100.0 0.0 0.0 89.3 ...ib/TM/Utils/TreeWalker.pm 100.0 100.0 n/a 100.0 0.0 0.0 96.0 ...ib/TM/Workbench/Plugin.pm 100.0 n/a n/a 100.0 0.0 0.0 75.0 ...M/Workbench/Plugin/Tau.pm 87.5 50.0 n/a 80.0 0.0 0.0 73.1 yapp/astma-fact.yp 96.9 91.5 73.3 97.8 0.0 4.8 92.7 yapp/astma2-fact.yp 97.4 91.6 58.3 100.0 0.0 0.2 91.6 Total 76.8 45.2 40.2 91.2 57.0 100.0 63.8 ---------------------------- ------ ------ ------ ------ ------ ------ ------ SEE ALSO
TM COPYRIGHT AND LICENSE
Copyright 200[8] by Robert Barta, <drrho@cpan.org> This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.10.1 2008-10-05 TM::Coverage(3pm)
All times are GMT -4. The time now is 02:14 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy