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
rbox(1) 						      General Commands Manual							   rbox(1)

NAME
rbox - generate point distributions for qhull SYNOPSIS
Command "rbox" (w/o arguments) lists the options. DESCRIPTION
rbox generates random or regular points according to the options given, and outputs the points to stdout. The points are generated in a cube, unless 's' or 'k' option is given. The format of the output is the following: first line contains the dimension and a comment, sec- ond line contains the number of points, and the following lines contain the points, one point per line. Points are represented by their coordinate values. EXAMPLES
rbox 10 10 random points in the unit cube centered at the origin. rbox 10 s D2 10 random points on a 2-d circle. rbox 100 W0 100 random points on the surface of a cube. rbox 1000 s D4 1000 random points on a 4-d sphere. rbox c D5 O0.5 a 5-d hypercube with one corner at the origin. rbox d D10 a 10-d diamond. rbox x 1000 r W0 100 random points on the surface of a fixed simplex rbox y D12 a 12-d simplex. rbox l 10 10 random points along a spiral rbox l 10 r 10 regular points along a spiral plus two end points rbox 1000 L10000 D4 s 1000 random points on the surface of a narrow lens. rbox c G2 d G3 a cube with coordinates +2/-2 and a diamond with coordinates +3/-3. rbox 64 M3,4 z a rotated, {0,1,2,3} x {0,1,2,3} x {0,1,2,3} lattice (Mesh) of integer points. 'rbox 64 M1,0' is orthogonal. rbox P0 P0 P0 P0 P0 5 copies of the origin in 3-d. Try 'rbox P0 P0 P0 P0 P0 | qhull QJ'. r 100 s Z1 G0.1 two cospherical 100-gons plus another cospherical point. 100 s Z1 a cone of points. 100 s Z1e-7 a narrow cone of points with many precision errors. OPTIONS
n number of points Dn dimension n-d (default 3-d) Bn bounding box coordinates (default 0.5) l spiral distribution, available only in 3-d Ln lens distribution of radius n. May be used with 's', 'r', 'G', and 'W'. Mn,m,r lattice (Mesh) rotated by {[n,-m,0], [m,n,0], [0,0,r], ...}. Use 'Mm,n' for a rigid rotation with r = sqrt(n^2+m^2). 'M1,0' is an orthogonal lattice. For example, '27 M1,0' is {0,1,2} x {0,1,2} x {0,1,2}. '27 M3,4 z' is a rotated integer lattice. s cospherical points randomly generated in a cube and projected to the unit sphere x simplicial distribution. It is fixed for option 'r'. May be used with 'W'. y simplicial distribution plus a simplex. Both 'x' and 'y' generate the same points. Wn restrict points to distance n of the surface of a sphere or a cube c add a unit cube to the output c Gm add a cube with all combinations of +m and -m to the output d add a unit diamond to the output. d Gm add a diamond made of 0, +m and -m to the output Pn,m,r add point [n,m,r] to the output first. Pad coordinates with 0.0. n Remove the command line from the first line of output. On offset the data by adding n to each coordinate. t use time in seconds as the random number seed (default is command line). tn set the random number seed to n. z generate integer coordinates. Use 'Bn' to change the range. The default is 'B1e6' for six-digit coordinates. In R^4, seven-digit coordinates will overflow hyperplane normalization. Zn s restrict points to a disk about the z+ axis and the sphere (default Z1.0). Includes the opposite pole. 'Z1e-6' generates degener- ate points under single precision. Zn Gm s same as Zn with an empty center (default G0.5). r s D2 generate a regular polygon r s Z1 G0.1 generate a regular cone BUGS
Some combinations of arguments generate odd results. Report bugs to qhull_bug@qhull.org, other correspondence to qhull@qhull.org SEE ALSO
qhull(1) AUTHOR
C. Bradford Barber c/o The Geometry Center 400 Lind Hall 207 Church Street S.E. Minneapolis, MN 55455 Geometry Center August 10, 1998 rbox(1)
All times are GMT -4. The time now is 12:34 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy