Sponsored Content
Full Discussion: Shortening Numbers
Top Forums Shell Programming and Scripting Shortening Numbers Post 302165338 by Jonny2Vests on Thursday 7th of February 2008 01:19:45 PM
Old 02-07-2008
Shortening Numbers

Hi,

I'm using ksh and I'm trying to shorten a column of figures. For example, I'd like to turn:

3456789.9876 to 89.98
567.4956 to 67.49
4669493932.34564 to 32.34

... so the input figure will vary in length, I'm not worried about rounding, I just want the two figures either side of the dp. I probably know how to do it in awk and cut etc I just wondered if there was a more elegant way using say a number format in something like printf.

So far I haven't found a number format that will exclude figures starting from the extreme left (the millions, 100,000s etc). Anyone?

Last edited by Jonny2Vests; 02-07-2008 at 02:49 PM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

seperating records with numbers from a set of numbers

I have two files one (numbers file)contains the numbers(approximately 30000) and the other file(record file) contains the records(approximately 40000)which may or may not contain the numbers from that file. I want to seperate the records which has the field 1=(any of the number from numbers... (15 Replies)
Discussion started by: Shiv@jad
15 Replies

2. Shell Programming and Scripting

read numbers from file and output which numbers belongs to which range

Howdy experts, We have some ranges of number which belongs to particual group as below. GroupNo StartRange EndRange Group0125 935300 935399 Group2006 935400 935476 937430 937459 Group0324 935477 935549 ... (6 Replies)
Discussion started by: thepurple
6 Replies

3. UNIX for Dummies Questions & Answers

Replace US numbers with European numbers

hey, I have a file with numbers in US notation (1,000,000.00) as well as european notation (1.000.000,00) i want all the numbers to be in european notation. the numbers are in a text file, so to prevent that the regex also changes the commas in a sentence/text i thought of: sed 's/,/\./'... (2 Replies)
Discussion started by: FOBoy
2 Replies

4. Shell Programming and Scripting

Directory path shortening ????

As it was a new topic i started a new thread. There are different Directories under "$HOME/rsh/Desktop/at/bin/bellhop/ and $HOME/rsh/Desktop/at/examples/" i want to perform some operation like cp or mv Is it possible to do R=$HOME/rsh/Desktop/at/bin/bellhop/... (1 Reply)
Discussion started by: shashi792
1 Replies

5. Shell Programming and Scripting

the smallest number from 90% of highest numbers from all numbers in file

Hello All, I am having problem to find what is the smallest number from 90% of highest numbers from all numbers in file. I am having file with thousands of lines and hundreds of columns. I am familiar mainly with bash but I am open to whatever suggestion witch will lead to the solutions. If I... (11 Replies)
Discussion started by: Apfik
11 Replies

6. UNIX for Dummies Questions & Answers

Print numbers and associated text belonging to an interval of numbers

##### (0 Replies)
Discussion started by: lucasvs
0 Replies

7. Shell Programming and Scripting

file name shortening for multiple directories

there was a post previously about this from around 2010 but i was unable to get the suggested scripts there to work. the following code works for me when it's saved inside the directory of files whose names i want to shorten, but i would like to be able to store it in a file with a list of ... (4 Replies)
Discussion started by: giseismology
4 Replies

8. Shell Programming and Scripting

Shortening a awk command

The purpose of the below is to grab the 9th field of the data in "$epochtimeframe". and then translate that data (which is an epoch time), into a human readable form. echo $epochtimeframe | awk -F"--" '{print $9}' | awk -F"," '{print $2}' | perl -pe 's/(\d+)/localtime($1)/e' i'm sure many... (10 Replies)
Discussion started by: SkySmart
10 Replies

9. Shell Programming and Scripting

Adding (as in arithmetic) to numbers in columns in file, and writing new file with new numbers

Hi again. Sorry for all the questions — I've tried to do all this myself but I'm just not good enough yet, and the help I've received so far from bartus11 has been absolutely invaluable. Hopefully this will be the last bit of file manipulation I need to do. I have a file which is formatted as... (4 Replies)
Discussion started by: crunchgargoyle
4 Replies

10. UNIX for Beginners Questions & Answers

Decimal numbers and letters in the same collums: round numbers

Hi! I found and then adapt the code for my pipeline... awk -F"," -vOFS="," '{printf "%0.2f %0.f\n",$2,$4}' xxx > yyy I add -F"," -vOFS="," (for input and output as csv file) and I change the columns and the number of decimal... It works but I have also some problems... here my columns ... (7 Replies)
Discussion started by: echo manolis
7 Replies
ps2frag(1)						      General Commands Manual							ps2frag(1)

NAME
ps2frag - obsolete shell script for the PSfrag system. IMPORTANT NOTICE
The new PSfrag system no longer requires the ps2frag script; instead, it handles the processing entirely within TeX/LaTeX and DVIPS. I'm sure you will agree that never needing to run ps2frag again is a nice convenience! However, there are two significant differences in the way this new version of PSfrag works. Please make yourself aware of them: 1) XDvi is no longer able to determine where your PSfrag replacements should go, so instead it lines them up in a vertical list to the left of the figure. This allows you to confirm that they have been typeset properly, at least. However, to confirm that PSfrag positions your replacements properly, you will have to view the PostScript version of your file with a viewer like GhostView, or print it out. This seems to be the only disadvantage to the elimination of the pre-processing step. 2) If you embed ' ex' commands inside your figures, you now need to explicitly _tell_ PSfrag to process these commands. To do so, use usepackage[scanall]{psfrag} instead of usepackage{psfrag} at the beginning of your LaTeX file. If you only use ' ex' commands in a small number of figures, then a more efficient might be to turn on ' ex'-scanning only for those fig- ures. To do that, add the command 'psfragscanon' immediately before each relevant includegraphics or epsfbox command. NOTES
See the PSfrag documentation for further information. SEE ALSO
dvips(1), gs(1), ghostview(1), latex(1) AUTHORS
psfrag@rascals.stanford.edu The PSfrag maintainer's mailing list. TeXware Feb 95 ps2frag(1)
All times are GMT -4. The time now is 02:05 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy