08-26-2010
Quote:
Originally Posted by
Daniel8472
Looks good! I am just wondering where the 3 is coming from (is the value rounded?). In the example the highest value is 0.34913E+01 for $2.
And another question just for my understanding. Where is specified that with starting to read a new file variable h is reset to 0 in order to extract the highest value of this specific file?
I try to grasp as much as possible that is why I ask so much
Cheers,
Daniel
Edit:
O maybe I got it! Right after begin you set h=0.
Edit2:
Oh now I got it, printf "%s\n%d\n" gives me header as a string and h as decimal expression and thus 3
Correct.
"BEGIN { h=0 }" initializes h(highest value) to zero so it can be used to compare with all $2 in the file.
And, actually, you can use
printf "%e", number to print numbers in exponential format, and
printf "%f", number in float point.
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
I have a program that is reading strings into a vector from a file. Currently I am using this command:
a.out < file1
The program runs and prints the contents of the vector to the screen, like its supposed to. The problem is that it needs to read in 3 files to fill the vector. Is there anyway... (4 Replies)
Discussion started by: Matrix_Prime
4 Replies
2. Shell Programming and Scripting
Hi,
I needs to split *.txt files from single directory depends on the some mutltiple input values. i have wrote the code like below
for file in *.txt
do
grep -i -h "value1|value2" $file > $file;
done.
My requirment is more input values needs to be given in grep; let us say 50... (3 Replies)
Discussion started by: arund_01
3 Replies
3. Shell Programming and Scripting
I have a program that runs like "cat f1 - f2 -", I need to write shell script to run the program whose standard input will be redirected from 2 files. I spend a whole day on it, but didn't figure out. Can someone help me out? Thanks! (8 Replies)
Discussion started by: microstarwwx
8 Replies
4. Shell Programming and Scripting
Hey everybody, I have a script for making a string substitution in a file. I am trying to modify it in order to make the same modifcation to multiples files. here is what I have so far.
#!/bin/csh
set p1="$1"
shift
set p2="$1"
shift
foreach x ($*)
if ( { grep -w -c "$p1" $x } ) then
mv... (7 Replies)
Discussion started by: iwatk003
7 Replies
5. UNIX for Advanced & Expert Users
Hi,
I am trying to come up with a script, and would like the script to pick all the files place within a folder and interactive take my yes/no before processing within the command. Could you someone help me in modifying the script :
#!/bin/bash
#
LDIF_FILES="File Name"
for MY_FILE... (5 Replies)
Discussion started by: john_prince
5 Replies
6. UNIX for Dummies Questions & Answers
I have multiple input files that I want to manipulate using a shell script. The files are called 250.1 through 250.1000 but I only want the script to manipulate 250.300 through 250.1000. Before I was using the following script to manipulate the text files:
for i in 250.*; do
|| awk... (4 Replies)
Discussion started by: evelibertine
4 Replies
7. Shell Programming and Scripting
Hi!
I'm new in awk and I need some help.
I have a folder with a lot of files and I need that awk do something in each file and print a new file with the output. The input file name should be modified when I print the outpu files.
Thanks in advance for help!
:-)
ciao (5 Replies)
Discussion started by: gabrysfe
5 Replies
8. Shell Programming and Scripting
Hello,
I'm trying to figure out how best to approach this script, and I have very little experience, so I could use all the help I can get. :wall:
I regularly need to delete files from many directories.
A file with the same name may exist any number of times in different subdirectories.... (3 Replies)
Discussion started by: *ShadowCat*
3 Replies
9. Shell Programming and Scripting
Hi ,
I am a newbie!!!
I want to develop a script for deleting files older than x days from multiple paths. Now I could reach upto this piece of code which deletes files older than x days from a particular path. How do I enhance it to have an input from a .txt file or a .dat file? For eg:... (12 Replies)
Discussion started by: jhilmil
12 Replies
10. Shell Programming and Scripting
Hi,
I have many test*.ft1 files to which I want to read as input for a script called
pipe2txt.tcl and print the output in each separate file.
For example,
pipe2txt.tcl < test001.ft1 > test001.txt
How can I read many files in this maner?
thank you very much,
Best,
Pahuja (5 Replies)
Discussion started by: Pahuja
5 Replies
ECVT(3) BSD Library Functions Manual ECVT(3)
NAME
ecvt, fcvt, gcvt -- convert double to ASCII string
SYNOPSIS
#include <stdlib.h>
char *
ecvt(double value, int ndigit, int * restrict decpt, int * restrict sign);
char *
fcvt(double value, int ndigit, int * restrict decpt, int * restrict sign);
char *
gcvt(double value, int ndigit, char *buf);
DESCRIPTION
These functions are provided for compatibility with legacy code. New code should use the snprintf(3) function for improved safety and porta-
bility.
The ecvt(), fcvt() and gcvt() functions convert the double precision floating-point number value to a NUL-terminated ASCII string.
The ecvt() function converts value to a NUL-terminated string of exactly ndigit digits and returns a pointer to that string. The result is
padded with zeroes from left to right as needed. There are no leading zeroes unless value itself is 0. The least significant digit is
rounded in an implementation-dependent manner. The position of the decimal point relative to the beginning of the string is stored in decpt.
A negative value indicates that the decimal point is located to the left of the returned digits (this occurs when there is no whole number
component to value). If value is zero, it is unspecified whether the integer pointed to by decpt will be 0 or 1. The decimal point itself
is not included in the returned string. If the sign of the result is negative, the integer pointed to by sign is non-zero; otherwise, it is
0.
If the converted value is out of range or is not representable, the contents of the returned string are unspecified.
The fcvt() function is identical to ecvt() with the exception that ndigit specifies the number of digits after the decimal point (zero-padded
as needed).
The gcvt() function converts value to a NUL-terminated string similar to the %g printf(3) format specifier and stores the result in buf. It
produces ndigit significant digits similar to the %f printf(3) format specifier where possible. If ndigit does allow sufficient precision,
the result is stored in exponential notation similar to the %e printf(3) format specifier. If value is less than zero, buf will be prefixed
with a minus sign. A decimal point is included in the returned string if value is not a whole number. Unlike the ecvt() and fcvt() func-
tions, buf is not zero-padded.
RETURN VALUES
The ecvt(), fcvt() and gcvt() functions return a NUL-terminated string representation of value.
WARNINGS
The ecvt() and fcvt() functions return a pointer to internal storage space that will be overwritten by subsequent calls to either function.
The maximum possible precision of the return value is limited by the precision of a double and may not be the same on all architectures.
The snprintf(3) function is preferred over these functions for new code.
SEE ALSO
printf(3), strtod(3)
STANDARDS
The ecvt(), fcvt() and gcvt() functions conform to IEEE Std 1003.1-2001 (``POSIX.1'').
BSD
May 31, 2007 BSD