Sponsored Content
Top Forums Shell Programming and Scripting Float number format problem -Awk Post 302441632 by jaduks on Sunday 1st of August 2010 11:51:16 PM
Old 08-02-2010
Code:
$ awk '{print $1,"\t",(($2+$3)/2)-x,"\t",(($2+$3)/2)+x,"\t",$4,"\t",$5}' x=500 file.txt 
cX 	 165112764 	 165113764 	 27 	 96.7
cX 	 165142764 	 165143764 	 14 	 53.73
cX 	 1.65325e+08 	 1.65326e+08 	 180 	 55.96

$ awk '{printf ("%s\t%0.0f\t%0.0f\t%0.0f\t%0.2f\n", $1, (($2+$3)/2)-500, (($2+$3)/2)+500, $4, $5)}' file.txt 

cX	165112764	165113764	27	96.70
cX	165142764	165143764	14	53.73
cX	165324888	165325888	180	55.96

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Integer/Float Script Problem

Hi, I have a script which takes a value from a file and performs calculations on it. Trouble is that this value is a float not an integer and it errors at the decimal point! eg. 94.62 I would like to be able to detect the length of the float (in this above case, 5 characters), and simply do a... (2 Replies)
Discussion started by: danhodges99
2 Replies

2. Shell Programming and Scripting

comparing float with int / number

Hi all, I'm looking to modify a script to check disk space usage. Here is the code at the moment: # # The control file, MONITOR_DISK_SPACE, must be in the format ... Drive:;threshold_percentage # eg. # C:;95 # D:;98 # E:;90 # # For each line in the control file (MONITOR_DISK_SPACE)... (2 Replies)
Discussion started by: lelliott
2 Replies

3. Programming

math.h: float ceilf(float x)

Good morning, I'm testing the use of ceilf: /*Filename: str.c*/ #include <stdio.h> #include <math.h> int main (void) { float ceilf(float x); int dev=3, result=0; float tmp = 3.444f; printf("Result: %f\n",ceilf(tmp)); return 0; } (1 Reply)
Discussion started by: jonas.gabriel
1 Replies

4. Shell Programming and Scripting

Problem with float calculation and awk

Hi All, can some body help me to script the below logic. Basically am facing problem with float calculation. Also i need this to be done inside a single awk. I tried lot of tuning but still nothing is getting displayed, nor any errors param=50 value=19.23 for(i=0;i<4;i++) {... (2 Replies)
Discussion started by: jisha
2 Replies

5. Shell Programming and Scripting

How to format the output using float in awk{printf}

Hi I'm using awk to manipulate the data in the 6th field of the file xxx_yyy.hrv. The sample data that is available in this field is given below 220731.7100000000000000 When i tried using this command cat xxx_yyy.hrv | awk '{printf("%23.16f\n",$6*-1)}' I get the output as... (4 Replies)
Discussion started by: angelarosh
4 Replies

6. Shell Programming and Scripting

awk:How to format a number?

Hello, I need to format a number..like 12900 should be printed as 12,900 and 1209 as 1,209 and so on. (Just like we do in excel). Can this be done in awk. any printf options we have?Please suggest me. Thanks! (8 Replies)
Discussion started by: vijay_0209
8 Replies

7. Shell Programming and Scripting

printf (awk,perl,shell) float rounding issue

Hi guys, could someone throw some light on the following behaviour of printf (I'll start with info about the system and the tool/shell/interpreter versions)?: $ uname -a Linux linux-86if.site 3.1.0-1.2-desktop #1 SMP PREEMPT Thu Nov 3 14:45:45 UTC 2011 (187dde0) x86_64 x86_64 x86_64... (9 Replies)
Discussion started by: elixir_sinari
9 Replies

8. Shell Programming and Scripting

[awk] rounding a float number?

Heyas Trying to calculate the total size of a file by reading its bitrate. Code snippet: fs_expected() { # # Returns the expected filesize in bytes # pr_str() { ff=$(cat $TMP.info) d="${ff#*bitrate: }" echo "${d%%,*}" | $AWK '{print $1}' | head -n 1 } t_BYTERATE=$((... (9 Replies)
Discussion started by: sea
9 Replies

9. Shell Programming and Scripting

Sed/awk command to convert number occurances into date format and club a set of lines

Hi, I have been stuck in this requirement where my file contains the below format. 20150812170500846959990854-25383-8.0.0 "ABC Report" hp96880 "4952" 20150812170501846959990854-25383-8.0.0 End of run 20150812060132846959990854-20495-8.0.0 "XYZ Report" vg76452 "1006962188"... (6 Replies)
Discussion started by: Chinmaya Kabi
6 Replies

10. Programming

Python : Problem with " TypeError: float() argument must be a string or a number "

Hello ! I'm creating a CGI which allow to display graph from some data. The datas looks like : 2020-01-13-00-00,384.00,350.00 2020-01-13-06-00,384.00,350.00 2020-01-13-12-00,384.00,350.00 2020-01-13-18-00,384.00,350.00 2020-01-14-00-00,384.00,350.00... (1 Reply)
Discussion started by: Tim2424
1 Replies
RDN(3pm)						User Contributed Perl Documentation						  RDN(3pm)

NAME
X500::RDN - handle X.500 RDNs (Relative Distinguished Names), parse and format them SYNOPSIS
use X500::RDN; my $rdn = new X500::RDN ('c'=>'DE'); my $c = $rdn->getAttributeValue ('c'); DESCRIPTION
This module handles X.500 RDNs (Relative Distinguished Names). This is a supporting module for X500::DN. Methods o $object = new X500::RDN ('type'=>'value', 'type'=>'value', ...); Creates an RDN object from argument pairs, each pair an attribute type and value. With more than one pair as arguments, you will get a multi-valued RDN. o $object->isMultivalued(); Returns whether the RDN is multi-valued. o $object->getAttributeTypes(); Returns the RDN's attribute types, a list of strings. o $object->getAttributeValue (type); Returns the RDN attribute's value. o $object->getRFC2253String(); Returns the RDN as a string formatted according to RFC 2253 syntax. o $object->getX500String(); Returns the RDN as a string formatted according to X.500 syntax. NOTE: This is a hack, there is no definition for a X.500 string syntax!? o $object->getOpenSSLString(); Returns the RDN as a string formatted according to one of openssl's syntaxes. Croaks on multi-valued RDNs. EXPORT None. BUGS
AUTHOR
Robert Joop <yaph-070708@timesink.de> COPYRIGHT
Copyright 2002 Robert Joop. All Rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. SEE ALSO
X500::DN, perl. perl v5.10.0 2007-07-08 RDN(3pm)
All times are GMT -4. The time now is 02:29 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy