Sponsored Content
Top Forums Shell Programming and Scripting using awk to print absolute value Post 302451580 by dealerso on Tuesday 7th of September 2010 09:28:36 AM
Old 09-07-2010
using awk to print absolute value

Hi,
I have a file contaning some variables with negative values, but i just want to print the positive value
Code:
awk -F"|" '$2<0 { print $1,$2 }' tom.unl > tee.unl

i want the $2 = absolute value eg

-200 should print 200

How can i do this.

Last edited by Franklin52; 09-08-2010 at 04:38 AM.. Reason: Please use code tags!
 

10 More Discussions You Might Find Interesting

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

2. Shell Programming and Scripting

awk - print

Hi all, I have script below: #!/bin/sh $name=blah awk -F: -v user="$name" '$1 == user{print $1 ":" $2 ":" $3 ":" $4}' /etc/shadow > /tmp/shadow.tmp based on above, it will only print one line which is "blah" username details. What do i need to do to print all contents of shadow... (6 Replies)
Discussion started by: c00kie88
6 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

print through AWK

Hi friends I need one help from you . I want to print name='JACK' through . how can i make it . awk '{print "name=jack"}' it ll print name=JACK (6 Replies)
Discussion started by: imipsita.rath
6 Replies

5. Shell Programming and Scripting

Print using awk

Hi.. I have two files. contents of the files are as below. header1.dat ------------- This is a header record. header2.dat ------------- This is a header record. Date:2011-01-05 I am executing the below scripts. HEADER1=`cat header1.dat` HEADER2=`cat header2.dat` awk 'BEGIN... (2 Replies)
Discussion started by: 46019
2 Replies

6. Shell Programming and Scripting

AWK print AWK command

awk '{print "awk '{sub(/pdb_00/,"pdb_"$0"_00"); print}' pdb_"$0"_00.namd > tempo"; print "mv tempo pdb_"$0"_00.namd"}' datA2.dat > copy_script2.bash This works when trying to print 'sed etc. etc' but if I switch to using AWK to print a set of AWK commands it doesn't work... e.g. this... (3 Replies)
Discussion started by: chrisjorg
3 Replies

7. UNIX for Dummies Questions & Answers

Absolute minimum value of a number using awk

Hi, I have got a file in the following format: 4300 23695 4305 03591 4400 125368 I need to sort this file to find the minimum absolute value of the numbers starting from 6th pos, so the expected output is:- 4300 23569 4305 01359 4400 123568 I tried to cut out the file from 6th... (7 Replies)
Discussion started by: roy121
7 Replies

8. Shell Programming and Scripting

awk Print New Column For Every Two Lines and Match On Multiple Column Values to print another column

Hi, My input files is like this axis1 0 1 10 axis2 0 1 5 axis1 1 2 -4 axis2 2 3 -3 axis1 3 4 5 axis2 3 4 -1 axis1 4 5 -6 axis2 4 5 1 Now, these are my following tasks 1. Print a first column for every two rows that has the same value followed by a string. 2. Match on the... (3 Replies)
Discussion started by: jacobs.smith
3 Replies

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

10. Shell Programming and Scripting

awk Print help

Hi, I got the output for the last command using the below command last -w -F | awk '{print $1","$3","$5$6$7$8","$11$12$13$14","$15}' | tac | tr ',' '\t' Now for the same output i want to add the below column names and then copy to csv file or xls file. Can someone help me out here. ... (9 Replies)
Discussion started by: ahmed.vaghar
9 Replies
ATAN2(3)						     Linux Programmer's Manual							  ATAN2(3)

NAME
atan2, atan2f, atan2l - arc tangent function of two variables SYNOPSIS
#include <math.h> double atan2(double y, double x); float atan2f(float y, float x); long double atan2l(long double y, long double x); Link with -lm. Feature Test Macro Requirements for glibc (see feature_test_macros(7)): atan2f(), atan2l(): _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE >= 600 || _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L; or cc -std=c99 DESCRIPTION
The atan2() function calculates the principal value of the arc tangent of y/x, using the signs of the two arguments to determine the quad- rant of the result. RETURN VALUE
On success, these functions return the principal value of the arc tangent of y/x in radians; the return value is in the range [-pi, pi]. If y is +0 (-0) and x is less than 0, +pi (-pi) is returned. If y is +0 (-0) and x is greater than 0, +0 (-0) is returned. If y is less than 0 and x is +0 or -0, -pi/2 is returned. If y is greater than 0 and x is +0 or -0, pi/2 is returned. If either x or y is NaN, a NaN is returned. If y is +0 (-0) and x is -0, +pi (-pi) is returned. If y is +0 (-0) and x is +0, +0 (-0) is returned. If y is a finite value greater (less) than 0, and x is negative infinity, +pi (-pi) is returned. If y is a finite value greater (less) than 0, and x is positive infinity, +0 (-0) is returned. If y is positive infinity (negative infinity), and x is finite, pi/2 (-pi/2) is returned. If y is positive infinity (negative infinity) and x is negative infinity, +3*pi/4 (-3*pi/4) is returned. If y is positive infinity (negative infinity) and x is positive infinity, +pi/4 (-pi/4) is returned. ERRORS
No errors occur. CONFORMING TO
C99, POSIX.1-2001. The variant returning double also conforms to SVr4, 4.3BSD, C89. SEE ALSO
acos(3), asin(3), atan(3), carg(3), cos(3), sin(3), tan(3) COLOPHON
This page is part of release 3.53 of the Linux man-pages project. A description of the project, and information about reporting bugs, can be found at http://www.kernel.org/doc/man-pages/. 2010-09-20 ATAN2(3)
All times are GMT -4. The time now is 08:44 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy