Sponsored Content
Full Discussion: Using sed to round a number
Top Forums Shell Programming and Scripting Using sed to round a number Post 302569497 by GmGeubt on Monday 31st of October 2011 01:40:12 PM
Old 10-31-2011
Using sed to round a number

Hey everyone, I was wondering if i am able to write a sed command to round a number to two decimal places. So for example:

1.58674
would be
1.58

I just want to chop off the numbers to the right of the second digit after the period. I know this is probably trivial but the closest i got was

sed 's/[.].*$//'

which deletes everything after the period including the period. Thanks.
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

how to round a value

Hello, In a unix shell script,i want to round a variabele to a nearest number Ex: set count=104.4 How can i round that to 105.? Thanks, Sateesh (2 Replies)
Discussion started by: kotasateesh
2 Replies

2. Shell Programming and Scripting

round in KSH

Is there an easy way to round a number up in Korn shell? ie. 10.4 --> 11 Thanks. (6 Replies)
Discussion started by: here2learn
6 Replies

3. Shell Programming and Scripting

round a number

In a shell script - How do I round a decimal number (contained in a variable) to the nearest whole number? (2 Replies)
Discussion started by: achieve
2 Replies

4. Shell Programming and Scripting

Round the column value :

Hi .... Iam having the file ....in which 3rd column is numerical having 8 decimal part... i want that to cut to 2 decimal part ... Source File : E100|0|19940.10104030|0|1ABC E103|1|19942.10195849|3|0ABC E100|0|19943.10284858|0|1ABC I want to be ...... Reulst: ... (4 Replies)
Discussion started by: satyam_sat
4 Replies

5. Shell Programming and Scripting

Round with awk

Hi, I have a problem. Basically I dont know how to use awk. I have a script (below) which works fine. What I want to do is somehow "pipe" in the input say 4.5 and have it give the anwer, I dont want ot have to type it in, since it will be running in a script. Any ideas how to do this???? ... (1 Reply)
Discussion started by: AnnaLynn
1 Replies

6. Shell Programming and Scripting

it's urgent ! round number in perl scripting

my $number = 12.345673412 I need 3 digits after decimal or after dot(.) i mean , i need only 12.345 I used int(), ceil(), floor() but it gives me only 12 I need it. (10 Replies)
Discussion started by: pritish.sas
10 Replies

7. Shell Programming and Scripting

Round up the decimals

Hi All, I would like to do the following in the shell script 561.76 to 562 I tried using this echo 'scale=0; 749 * 75 /100 ' | bc but just returned only 561 Please help me . I appreciate your help Thanks rajeevm (13 Replies)
Discussion started by: rajeevm
13 Replies

8. Shell Programming and Scripting

How to round up value upto 2 decimal places using sed?

Please help me in rounding up value upto 2 decimal palces using sed command #!/usr/bin/bash a=15.42 b=13.33 c=`echo $a*$b |bc -l` echo $c above code is is giving output "205.5486" but i want the output as "205.55" Thank you... (15 Replies)
Discussion started by: ranabhavish
15 Replies

9. Shell Programming and Scripting

Round off Number in File

Hi Guys, i am having a csv file where i need to round off numerical column to 2 decimal precision in specific columns. i need to ignore the first two line i.e the header columns and manipulate rest of the lines of the csv file. My columns are specific i.e i need to round off only 2nd,4th and... (13 Replies)
Discussion started by: rohit_shinez
13 Replies
kdestroy(1m)															      kdestroy(1m)

NAME
kdestroy - Destroys a principal's login context and associated credentials SYNOPSIS
kdestroy [-c cache_name] [-e exp_period] [-r max_retry_of_readdir] OPTIONS
Specifies that the login context and associated credentials for cache_name should be destroyed instead of the default cache. Removes cre- dentials that have been expired for a period of time longer than the period of time specified by exp_period. Specifies the maximum number of retries. DESCRIPTION
The kdestroy command destroys a principal's login context and the principal's credentials. Until the credentials are reestablished by either executing the dce_login command or the kinit command, the principal and any processes created by the principal will be limited to unauthenticated access. Specify the expiration period in the following format: {num{interval}}... where: A number that specifies the number of interval A designator of the time period for num. interval can be any of the following: w - weeks d - days h - hours (default) m - minutes s - seconds For example, to destroy credentials that have been expired more than 5 days and 10 hours, the entry would be 5d10h. FILES
If the KRB5CCNAME environment variable is set, the default credentials cache. ([unix_id] is the decimal UNIX ID of the user.) NOTE
kdestroy provided under "/usr/bin" is part of Kerberos V5 client product. For DCE operations use "/opt/dce/bin/kdestroy". RELATED INFORMATION
Commands: klist(1m), kinit(1m). kdestroy(1m)
All times are GMT -4. The time now is 08:58 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy